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
silver...@videotron.ca
http://www.silverscripting.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to