creating new model object by passing a dictionary just like this
let article = Article(value: json)
the Article object is
import RealmSwift
import Foundation
class Article: Object {
dynamic var id = 0
and i get this error every time
Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '173' for property 'id''
(Disclaimer: I work for Realm)
That exception gets thrown if the data type of the item in the dictionary doesn't match the expected data type of the Realm property.
In this instance, I'm getting the feeling that id
is coming down as a string (Is it in quotes in the JSON string?), so subsequently trying to map it to an integer property won't work.
If this isn't the case, please see if you can post a copy of your JSON string so we can see if we can work out better what's going on. Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.