The block declaration with empty parenthesis:
void (^)()
has the same semantics as a function pointer with empty parenthesis:
void (*)()
It does not mean that there are no arguments. It means the arguments are not specified, therefore it opens the way to bugs since you can call it in the following ways:
void (^block)() = ...
block();
block(10);
block(@"myString");
When declaring blocks with no parameters, always use:
void (^)(void)
Apple was not doing that correctly everywhere and they are not probably fixing that for old APIs for compatibility reasons. You will have to keep that warning there until you move to the newer API.
You can also turn off that warning (-Wstrict-prototypes
):
or using #pragma
(thanks @davidisdk):
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
- (void)application:(UIApplication *)application
handleActionWithIdentifier:(NSString *)identifier
forRemoteNotification:(NSDictionary *)userInfo
withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)())completionHandler {
}
#pragma clang diagnostic pop
See the LLVM discussion here or the bug on openradar.
Note that's there was no change in the internal working of the APIs, all code will still work. We will only know that the API is not as good as it should be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With