在 Objective-C 类的 Swift 子类中重写时,我收到一条消息:
属性类型'BOOL'(又名'bool')与继承自'ChildClass'的类型'Boolean'(又名'unsigned char')不兼容
我尝试使用其他布尔类型,但它不起作用。
知道如何在 Swift 中正确覆盖 Objc BOOL
Swift 代码(子类):
override var myVar: Bool {
get {
return something ? true : myVar
}
set {
myVar = newValue
}
}
对象父声明:
@property(atomic) Boolean isLoading;
出现警告的 Swift 桥接头:
SWIFT_CLASS("_TtC6Module30ChildClass")
@interface ChildClass : ParentClass
@property (nonatomic) BOOL myVar; //<----- Here
@end