0

I am using realm-cocoa(v1.0.1) with a Swift 2.0 project (need objective-c interoperability) and am having trouble overriding the linkingObjectsProperties method.

I've followed the Realm documentation (https://realm.io/docs/objc/latest/#inverse-relationships) and defined my function override in my RLMObject subclass as follows:

override class func linkingObjectsProperties() -> NSDictionary {
    return ["owners": RLMPropertyDescriptor(withClass: Person.self, propertyName: "dogs")]
}

The compiler then complains, saying "Method does not override any method from its superclass".

If I prefix the definition with @objc, the error changes to "Overriding method with selector 'linkingObjectsProperties' has incompatible type '() -> NSDictionary'

Any ideas?

Thanks!

4

1 回答 1

0

+[RLMObject linkingObjectsProperties]暴露给 Swift 作为class func linkingObjectsProperties() -> [String : RLMPropertyDescriptor]. 更新您的覆盖以匹配该签名应该可以解决问题。

于 2016-06-29T23:11:47.553 回答