CoreData relationship/KVC question
CoreData relationship/KVC question
- Subject: CoreData relationship/KVC question
- From: Jean-Nicolas Jolivet <email@hidden>
- Date: Fri, 30 Jan 2009 14:14:27 -0500
I've been working on my first CoreData project and I have a question
regarding dynamically generated accessors for to-many relationships
and KVC...
I'll keep it as simple as possible, let's assume I have a Department
entity which contains many Employees entities....
from what I understand in the doc, CoreData should automatically
generate those methods for Department:
-addEmployees:(NSSet *)values
-addEmployeesObject:(NSManagedObject *)value
My question is, how would I access these 2 methods using KVC accessors?
For example, if I want to set the employee's name attribute I can
use: [anEmployee setValue:@"John Doe" forKey:@"name"];
Following this pattern, could I use
[aDeparment setValue:anEmployee forKey@"employees]; // Assuming
anEmployee is an NSManagedObject*
or
[aDeparment setValue:someEmployees forKey@"employees]; // Assuming
someEmployees is an NSSet*
In other words, are relationship also KVC and, will CoreData
aumatically call the correct method depending on the type of the
"value" I'm setting (either an NSSet or an NSManagedObject) ?
I know I can declare an NSManagedObject category with a bunch of
accessors etc.. to suppress compiler warning but I was wondering about
the KVC get/set as I am using them too....
Thank you!
Jean-Nicolas Jolivet
email@hidden
http://www.silverscripting.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden