nsmanagedobject - Core Data: Observing new Entity of certain type -
Whenever a unit of a certain type (and possibly altered / removed) is added, I must notify .
I've read this possible by adding a supervisor to managed objectcontact. However, I have not found a real way to do this.
I am doing:
[reference addObserver: Path to myself: @ "{myEntityName}" option: {I have tried many different values, but I have failed to understand which one to use} context: @ "newtext"]; Thanks for the help
Note: I'm obviously new to coredata / cocoa / purpose-c, and this is probably very basic, but very long Time has been followed for an answer.
BTW: This is a common question that is not able to get samples and / or explanations on the way to properly follow the changes in context objects. It is possible, but I lack a description:
First of all, do not confuse entities and objects . Institutions have similarities to classes and they are never added or removed from a managed object context. This is a managed object that is added or removed from a managed object context. Each managed object is placed in the unit in the data model, such that any other object instance is placed on a particular class.
Therefore, what you really want should be notified, when a controlled object is inserted / updated / removed from a particular unit.
The easiest way to handle this is:
NSManagedObjectContextObjectsDidChangeNotification one ?? | In which context a managed object has been inserted / updated / deleted. To find only managed objects for a particular unit, check the returned items by the key of the NSINSTAid Object, NSINattObject's, NSDiated Objects, and the keys of NSDiated Objects and then check the entity of each object. Alternatively, you use a custom NSManagedObject subclass and to issue an alert when the override awakeFromInsert is inserted for the first time. Please note that such functionality is rarely necessary when you prepare yourself a lot of notifications, then it usually indicates that your data model There is a need to try again to get more information. You usually need notifications because some of the key logic of the data model is not encoded in the core data but remains in the external object which requires information.
Comments
Post a Comment