2
SIAlertView是外部客觀C庫我在項目中使用斯威夫特3傷了我的目標C和斯威夫特處理器/關閉兼容性
在雨燕2.2這條線之下編譯罰款
class func showAlert(title title : String, message: String, confirmHandler: (SIAlertView!) -> Void) {
...
alertView.addButtonWithTitle(OK_TITLE, type: SIAlertViewButtonType.Default, handler: confirmHandler);
alertView.show();
}
但是現在在Swift 3中有一個錯誤消息說
Cannot convert value of type 'class func showAlert(title title : String, message: String, confirmHandler: (SIAlertView!) -> Void)' to expected argument type 'SIAlertViewHandler!'
從客觀C類我發現
SIAlertView.h
@class SIAlertView;
typedef void(^SIAlertViewHandler)(SIAlertView *alertView);
SIAlertView.m
- (void)addButtonWithTitle:(NSString *)title type:(SIAlertViewButtonType)type handler:(SIAlertViewHandler)handler
{
SIAlertItem *item = [[SIAlertItem alloc] init];
item.title = title;
item.type = type;
item.action = handler;
[self.items addObject:item];
}
有人能解釋這個嗎?因爲以前在斯威夫特工作正常2.2