Reputation: 17930
I've been confused about core data entities. Since you never allocate them do you need to retain them? When a view controller has an entity as one of its properties should it be weak when another view controller assigns the entity but strong when the view controller sets the property itself?
Upvotes: 2
Views: 751
Reputation: 6082
Core Data entity is just an object like any other, so you should follow memory management rules. You retain
entities when you need them and release
when you no longer need them.
For example: using sqlite backend, core data will cache loaded data to minimize amount of requests sent to db. But it can't keep all the records in memory and it should understand which entities you use and which don't, so it can release unused and free memory. In case using weak
properties you can end up with garbage pointer or nil instead of actual object.
Upvotes: 2