I am having trouble with swift closure syntax. I am trying to check the mute switch using Sharkfood which you can see here: http://sharkfood.com/content/Developers/content/Sound%20Switch/
The Block I'm trying to call is shown below.
typedef void(^SharkfoodMuteSwitchDetectorBlock)(BOOL silent);
This is how I'm trying to call it but it isn't working. I've tried a ton of different ways and I know I'm missing something little since I'm new to swift. The error I'm getting is:
'(Bool) -> Void' is not convertible to 'Bool'
On the first line of this code:
muteDetector.silentNotify({
(silent: Bool) -> Void in
println("this")
println("worked")
})
Any help would be greatly appreciated.
Never used that library, but looking at the documentation linked in your question I notice that
silentNotify
is a property:containing the block, so the error stating that a BOOL is expected makes sense.
Instead with your code you are probably trying to call this method:
I don't know which of the 2 you are attempting to do - if you want to call the block, then you have to just provide a bool:
if instead you want to register a new block (closure), then you have to use: