我的协议定义如下
@protocol BaseCell
-(void) configureCellData:(id)data index:(NSIndexPath*)indexPath
@end
然后在swift中我正在做以下事情:
@objc(MyCell)
class MyCell: UICollectionViewCell , BaseCell {
public func configureCellData(_ data: Any!, index: IndexPath!) {
}
}
然而,当我运行该类时,它为我提供了无法识别的选择器
编辑: 崩溃
NSInvalidArgumentException -[UICollectionViewCell configureCellData:index:]: unrecognized selector sent to instance 0x7fa09be01200
userInfo:(null)
call stack:(
0 CoreFoundation 0x0000000106e5534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010bbef21e objc_exception_throw + 48
2 CoreFoundation 0x0000000106ec4f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000106ddac15 ___forwarding___ + 1013
4 CoreFoundation 0x0000000106dda798 _CF_forwarding_prep_0 + 120