griotspeak
griotspeak

Reputation: 13247

How to make a Core Data Entity immutable?

Is there a best practice for making an entity immutable? Users create exercises in my app and some would like a means to 'lock' a file when it is complete. It seems ridiculous to add a 'locked' property and check that whenever a property is set, but is that 'the way' to do it?

Upvotes: 0

Views: 297

Answers (1)

Actually, adding a locked / immutable property is a perfectly adequate solution. I recently used such a scheme, using a locked NSDate property. So I know when the entity was locked.

As far as I know, there is no such thing in Core Data itself.

By the way, a locking scheme in Core Data itself would be quite complex, as relationships are involved. What if an entity part of a relationship of a locked entity is deleted? The delete is denied? Or the relationships are mutable even when the entity is not? There is no universal answer I think.

Upvotes: 2

Related Questions