[英]Realm - Swift store a protocol type
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? 有没有办法存储符合协议的属性?
不,Realm属性是单态的,Realm需要知道在初始化时将链接到的具体对象类型是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.