Is it bad form for managed objects to add themselves as observers of notifications? I have a managed object that has several transient properties and gets its data from a different store as described in the CoreData docs. If the store changes, the managed objects need to listen for this notification and act accordingly. I was worried that there might be some performance implications to having something like a managed object registering for notifications since there could be quite a lot of them and CoreData manages their lifecycles.
0
votes
I don't know what kind of application you are designing, but I am thinking about the fact that NSManagedObjects not loaded yet, probably need to be notified too. If this is the case, I would rather think about an util class listening to notification, which in turn go and modify the store, or lookup for live objects and merge changes.
- Leonardo
Once the managed object becomes loaded it would start with the most up to date data
- JPC
1 Answers
0
votes
JPC,
Based on my experience there could be few potential performance problems if you set a NSManagedObject as a observer. It could become a bottleneck, but it depends on the number of objects you have and on the type of notification you register for. Could say something more on it?
Said this, I suggest you to read parent-watching-its-child by Marcus Zarra. This article could guide you in the right track.
Hope that helps.