我有這樣的方法:Objective-C的不兼容的模塊類型錯誤
- (void)shareItems:(NSArray *)shareItems fromViewController:(UIViewController *)viewController anchorView:(UIView *)anchorView completion:(void (^)(NSString *activityType, BOOL, NSError *))completionHandler;
我只是想實現它的XCode 7.0.1和我收到以下錯誤信息:
如果你不能看到,我試圖執行:
[[VMSocialShareManager defaultManager] shareItems:shareItems fromViewController:self anchorView:shareCell completion:^(NSString *activityType, BOOL completed, NSError *error) {
...
}];
但得到的錯誤:
Incompatible block pointer types sending 'void (^)(NSString *__strong, BOOL, NSError *__strong)' to parameter of type 'void (^)(BOOL, NSString *__strong, NSError *__strong)'
OK,當然,我會盡量翻轉BOOL
和NSString
即使這是沒有意義的:
[[VMSocialShareManager defaultManager] shareItems:shareItems fromViewController:self anchorView:shareCell completion:^(BOOL completed, NSString *activityType, NSError *error) {
...
}];
但隨後即給出了錯誤:
Incompatible block pointer types sending 'void (^)(BOOL, NSString *__strong, NSError *__strong)' to parameter of type 'void (^)(NSString *__strong, BOOL, NSError *__strong)'
但問題是:如何在VMSocialShareManager_中實際聲明此方法? – matt
另請參見,一如既往http://fuckingblocksyntax.com/ –
@matt:問題的第一行是方法聲明。 – Ramsel