KexAri
KexAri

Reputation: 3977

Cannot call value of non-function type

Having issues trying to convert this to Swift 3.0.

I have:

public typealias CustomCompletionBlock = (_ image: UIImage?, _ error: Error?) -> Void
public var completionBlock : CustomCompletionBlock!

Later on in my code I want to set completionBlock e.g.:

self.completionBlock(image: nil, error: error)

But I get the error "Cannot call value of non-function type". What am I doing wrong here?

Upvotes: 1

Views: 3618

Answers (2)

PGDev
PGDev

Reputation: 24341

In CustomCompletionBlock signature,

public typealias CustomCompletionBlock = (_ image: UIImage?, _ error: Error?) -> Void

you have specified _ as the external parameter name for image and error variables. This means while calling CustomCompletionBlock you don't have to specify any parameter names. image and error are internal parameter names i.e. they must only be used within closure definition.

So you must call it like:

self.completionBlock(nil, error)

Upvotes: 3

tonik12
tonik12

Reputation: 613

Try to call it like this:

self.completionBlock(nil, error)

Upvotes: 1

Related Questions