【发布时间】:2018-03-30 07:12:25
【问题描述】:
在 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
}
}
Objc 父声明:
@property(atomic) Boolean isLoading;
出现警告的 Swift 桥接头:
SWIFT_CLASS("_TtC6Module30ChildClass")
@interface ChildClass : ParentClass
@property (nonatomic) BOOL myVar; //<----- Here
@end
【问题讨论】:
-
作为?布尔 - 也不起作用?
-
@SergeyHleb 抱歉,我不太清楚。我添加了代码来消除歧义。问题在于桥接头的声明
-
您实际上是否在使用/覆盖
isLoading变量? -
也许this可以帮助你?
标签: objective-c swift swift4.1