【发布时间】:2018-03-30 11:28:58
【问题描述】:
这就是我在 My Object 中声明 imageurls 的方式:
var imageURLs = List<String>()
和解析:
func mapping(map: Map) {
imageURLs <- map["image_urls"]
}
这就是我要解析的内容:
{ "image_urls": ["a"] }
最后上面的属性是空的。为什么?
使用 Realm 3.3,所以原语数组应该可以工作。
【问题讨论】:
-
试过 var imageURLs = [String]()
-
*** Terminating app due to uncaught exception 'RLMException', reason: 'Property 'imageURLs' is declared as 'NSArray', which is not a supported RLMObject property type. All properties must be primitives, NSString, NSDate, NSData, NSNumber, RLMArray, RLMLinkingObjects, or subclasses of RLMObject. -
你应该试试这个
let imageURLs = List<String>()看看这个realm.io/docs/swift/latest/#property-attributes -
然后将其声明为 RLMArray
-
Left side of mutating operator isn't mutable: 'imageURLs' is a 'let' constant
标签: ios swift realm objectmapper