gpt4 book ai didi

ios - linkingObjectsProperties 从 swift 2.0 覆盖

转载 作者:行者123 更新时间:2023-11-30 13:17:03 27 4
gpt4 key购买 nike

我正在将 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")]
}

然后编译器会提示,说“方法不会覆盖其父类(super class)中的任何方法”。

如果我在定义中添加 @objc 前缀,错误将更改为“使用选择器“linkingObjectsProperties”重写方法具有不兼容的类型“() -> NSDictionary”

有什么想法吗?

谢谢!

最佳答案

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

关于ios - linkingObjectsProperties 从 swift 2.0 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38111301/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com