
码
dynamic var complete: Bool? = nil
这是我的
错误
Property cannot be marked dynamic because its type cannot be represented in Objective-C
我知道这是与上面的帖子相同的代码和错误,但我很好奇,如果Realm文档说它支持它,他们还有另一种解决方法吗?
解决方法 来自 supported types和 optional properties的文档.
String,NSDate,NSDataand Object propertIEs can be optional. Storing optional numbers is done using 07002.
RealmOptionalsupportsInt,float,Double,Bool,and all of the sized versions ofInt(Int8,Int16,Int32,Int64).
因此,使用标准的swift语法很好地支持String,NSDate,NSData和Object类型的选项.
对于使用RealmOptional完成的其他数字类型(例如Bool).然后,要使用此RealmOptional类型的变量,您可以访问其value属性,该属性是一个可选的,表示您的基础值.
// deFinition (defined with let)let complete = RealmOptional<Bool>() // defaults to nil// usagecomplete.value = false // set non-nil value...complete.value = nil // set to nil again总结
以上是内存溢出为你收集整理的ios – Swift 2.0中的动态可选属性全部内容,希望文章能够帮你解决ios – Swift 2.0中的动态可选属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)