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
eg:
self.completionBlock(image: nil, error: error)
But I get the error "Cannot call value of non-function type" . What am I doing wrong here?
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 ie they must only be used within closure definition.
So you must call it like:
self.completionBlock(nil, error)
尝试这样称呼它:
self.completionBlock(nil, error)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.