linkingObjectsProperties 从 swift 2.0 覆盖
linkingObjectsProperties override from swift 2.0
我将 realm-cocoa(v1.0.1) 与 Swift 2.0 项目(需要 objective-c 互操作性)一起使用,并且在重写 linkingObjectsProperties 方法时遇到问题。
我遵循了 Realm 文档 (https://realm.io/docs/objc/latest/#inverse-relationships) 并在我的 RLMObject 子类中定义了我的函数覆盖,如下所示:
override class func linkingObjectsProperties() -> NSDictionary {
return ["owners": RLMPropertyDescriptor(withClass: Person.self, propertyName: "dogs")]
}
然后编译器报错,说 "Method does not override any method from its superclass"。
如果我在定义前加上@objc,错误会变为“使用选择器 'linkingObjectsProperties' 的覆盖方法具有不兼容的类型 '() -> NSDictionary'
有什么想法吗?
谢谢!
+[RLMObject linkingObjectsProperties]
作为 class func linkingObjectsProperties() -> [String : RLMPropertyDescriptor]
暴露给 Swift。更新覆盖以匹配该签名应该可以解决问题。
我将 realm-cocoa(v1.0.1) 与 Swift 2.0 项目(需要 objective-c 互操作性)一起使用,并且在重写 linkingObjectsProperties 方法时遇到问题。
我遵循了 Realm 文档 (https://realm.io/docs/objc/latest/#inverse-relationships) 并在我的 RLMObject 子类中定义了我的函数覆盖,如下所示:
override class func linkingObjectsProperties() -> NSDictionary {
return ["owners": RLMPropertyDescriptor(withClass: Person.self, propertyName: "dogs")]
}
然后编译器报错,说 "Method does not override any method from its superclass"。
如果我在定义前加上@objc,错误会变为“使用选择器 'linkingObjectsProperties' 的覆盖方法具有不兼容的类型 '() -> NSDictionary'
有什么想法吗?
谢谢!
+[RLMObject linkingObjectsProperties]
作为 class func linkingObjectsProperties() -> [String : RLMPropertyDescriptor]
暴露给 Swift。更新覆盖以匹配该签名应该可以解决问题。