Realm - Swift store a protocol type

拜拜、爱过 提交于 2019-12-22 09:38:52

问题


I have the following structure:

class Entity : Object {
    dynamic var Id = 0
    dynamic var Title = ""
    dynamic var Subtitle = ""
    var atttribute : MyProtocol?

}

Is there a way of storing something in attribute? Today is returning nil. If I add dynamic it returns the error:

Property cannot be marked dynamic because its type cannot be represented in Objective-C

Is there any way to store properties that conform to a Protocol as that?


回答1:


No. Realm properties are monomorphic, and Realm needs to know what the concrete object type that will be linked to is at initialization time.



来源:https://stackoverflow.com/questions/32250084/realm-swift-store-a-protocol-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!