My Swift 3.0 project uses an Objective-C library that defines a certain type (AsyncBlock
) as an Obj-C block:
typedef BOOL (^AsyncBlock)(id __nullable * __nonnull context);
In Swift 3.0 terms, that should translate into a non optional pointer to an optional value, so I figured I should be able to assign a variable of type AsyncBlock
to a closure defined in my swift 3 project as follows (not including bridging header and other details for brevity):
func closure(_ context: UnsafeMutablePointer<Any?>) -> Bool {
return true
}
var myClosureVariable: AsyncBlock = closure
The compiler disagrees: Cannot assign value of type '(UnsafeMutablePointer<Any?>) -> Bool' to type 'AsyncBlock'
- what am I doing wrong?