我有以下Objective C类标题:
@protocol CustomKeyboard;
@class CustomKeyboardView;
@protocol CustomKeyboardViewProtocol <NSObject>
- (void)customKeyboardView:(UIView<CustomKeyboard> *)customKeyboard numberPress:(UIButton *)sender;
@end
@protocol CustomKeyboard <NSObject>
@required
-(id)initWithDelegate:(id<CustomKeyboardViewProtocol>)delegate;
-(void)reload;
@property (nonatomic, weak) UITextField * textField;
@property (nonatomic, weak) id<CustomKeyboardViewProtocol> delegate;
@end
@interface CustomKeyboardView : UIView <CustomKeyboard>
{
IBOutlet UIView *keyboardView;
}
- (void)hide;
- (void)show;
@end
Swift中的这个类正在尝试采用该协议,但我收到的方法中的类型错误,并且自动完成已经消失:
extension MyViewController: CustomKeyboardViewProtocol {
func customKeyboardView(_ customKeyboard: UIView!, numberPress sender: UIButton!) {
}
}
错误说:
Candidate has non-matching type '(UIView!, UIButton!) -> ()'
任何线索,如果错误是因为协议中的循环依赖还是关于类型?我刚刚更新到Xcode 9和Swift 4,并更新到推荐的设置,它曾经工作得很好。