Say I have a class and its Realm representation that looks like this:
class Dog {
var identifier: String
var age: Int
...
override static func primaryKey() -> String? {
return "identifier"
}
}
Now here is what my new Identifier class looks like:
class Identifier {
var functionalId: String
var version: String
...
}
I need to replace my Dog's identifier String property to be an Identifier like this:
class Dog {
var identifier: Identifier
var age: Int
...
override static func primaryKey() -> String? {
return "identifier" // I need to change this
}
}
but I'm having a hard time replacing the content of the primaryKey() method:
How do I tell Realm to look for an object's sub property for the primaryKey() ?
I tried something like:
override static func primaryKey() -> String? {
return "identifier.functionalId"
}
But it seems that I was too naive, it won't work
** EDIT ** Following comments, here is the output of the crash I'm getting:
Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'identifier.functionalId' does not exist on object Dog
Sorry for bad English though, I couldn't find the words fir this simple problem, especially the title!