Reputation: 900
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''
Upvotes: 2
Views: 1283
Reputation: 15991
(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!
Upvotes: 1