【问题标题】:Realm - Swift store a protocol typeRealm - Swift 存储协议类型
【发布时间】:2015-08-27 12:59:48
【问题描述】:

我有以下结构:

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

}

有没有办法在属性中存储一些东西? 今天返回零。如果我添加动态它会返回错误:

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

有什么方法可以存储符合协议的属性吗?

【问题讨论】:

  • 你要延迟加载吗?

标签: ios swift realm


【解决方案1】:

没有。 Realm 属性是单态的,Realm 需要在初始化时知道​​将链接到的具体对象类型是什么。

【讨论】:

  • 我在 5 年零 2 个月后的今天看到了这个问题 :),我想知道领域属性仍然是单态的吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-09
  • 2015-04-14
  • 2017-08-06
  • 1970-01-01
相关资源
最近更新 更多