Reputation: 2258
I'm using Core Data in my project. I have an entity, EntityMO that has a 1-to-many optional relationship with RelationMO.
When I make the call myEntity.myRelation in my code (to see if the RelationMO object exists), is that going to cause a table lookup every time? Or is there some black magic happening with Core Data?
Upvotes: 0
Views: 61
Reputation: 125007
Or is there some black magic happening with Core Data?
Simply getting the object will usually not require accessing the data store, but the object you get in that case will be a fault, not the actual stored object. When you use the object, the fault will fire, causing the object to be realized. There are a few operations (e.g. -isEqual:
) that will not cause a fault to fire -- see the docs for more information.
Faults are realized behind the scenes and so may seem like black magic, but it's better to think of them as delayed gratification.
Upvotes: 1