I am trying to figure out that KVC mechanism provides some kind of help when dealing with relationship properties Which are the opposite relationships, one another. I will use the formal and standard department / staff example.
@ Interface department: NSOJject {NSMUTABEELE * employee; } @ Property (Maintaining) NSMutableArray * Employee; // Employee Array @ Enter @ Interface: KVC mode for changing employee: NSOJject {Department * Department; } @ Property (Maintenance) Department * Department; What kind of help does this KVC manage in both directions (with methods of abandoned KVV collection)? I am still in a conceptual state. I know that with core data, I can set clear inverse relationships and thus when I use [myDepartment insertObject: newEmployee inEmployeesAtIndex: lastIndex]; , then newEmployee.department is set to automatically < myDepartment , but can I get it only with KVC and Runtime? Or do I need core data?
Thank you in advance for help.
Edit is unrelated to some extent but it is also important, in my code I am going to retain the employee's property as the department But am I thinking if this will be the reason of maintaining a cycle?
There is nothing directly in key-value coding that will help you maintain a busy connection. You can take advantage of the key-value viewing to do this.
The main things you want to do are:
- Instead of subclassing NSObject for your own class classes, instead of just the square of NSManagedObject, because of all Afterwards you can not guarantee arbitrary NSObject subclasses will work with the system you come up with. (Alternatively, you can encrypt the need for everything they need in a protocol. EOF did this with the EOEnterpriseObject protocol.)
- To handle the observation of your unit sections, make NSManagedObjectContext Apply your own square equals, so they can ask them to keep upside-down on maintenance at the right time. pay attention. That the inverse maintenance is starting from KVO again triggering the KVO which will trigger the inverse maintenance and so on
- NSManagedObjectModel applies its own class hierarchy equally to NSManagedObjectContext in its equivalent examples What qualities do you know from your unit class can have opposite relationships, and what are they?
Given all of this, you probably want to use core data, because it does all already and has been done extensively over the years to do it well enough. See for
Comments
Post a Comment