Reputation: 536
Sometimes we may need to check if the realm object has primary key or not. Like if we want to do func add<S>(_ objects: S, update: UpdatePolicy = .error) where S : Sequence, S.Element : Object
. If an object already exists in the Realm with the specified primary key and the update policy is .modified
or .all
. The .error
is for objects without a primary key.
Upvotes: 2
Views: 540
Reputation: 536
using object.objectSchema.primaryKeyProperty == nil
to check if the object has the primary key or not.
Upvotes: 4