i am on macOS, objective-c. I included a Swift 5 framework and one thing i don't know is how to provide a closure.
This is the swift declaration:
var cancelledStateColorHandler: ((NSColor) -> NSColor)?
How do i pass a handler from objective-c to return an NSColor?
According to F*ck*ngBlockSyntax, we write a block as a var that way:
var cancelledStateColorHandler: ((NSColor) -> NSColor)?would translated into swift as@property (nonatomic, copy) NSColor * _Nonnull (^ _Nullable cancelledStateColorHandler)(NSColor * _Nonnull);. To simulate it, check your Project-Swift.h file.I tested with
And got:
Now, we only focus on the second part of the syntax, since the left part, is
yourInstance.cancelledStateColorHandlerSo we got: