Reputation: 7113
I'm trying to use a computed property in Realm and use it as primaryKey.
dynamic var eventPrimaryKey: String{
get{
return "\(ID)\(eventId)"
}
}
but I receive this error:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'eventPrimaryKey' does not exist on object
Upvotes: 2
Views: 2823
Reputation: 7340
You can't use computed property as a primary key, primary key should be stored in database. See more info about primary keys in docs.
Check out Ignored Properties also (note: read-only properties are automatically ignored).
Upvotes: 6