Re: Adding to-many objects programmatically
Re: Adding to-many objects programmatically
- Subject: Re: Adding to-many objects programmatically
- From: mmalc Crawford <email@hidden>
- Date: Fri, 15 Jan 2010 22:13:49 -0800
On Jan 15, 2010, at 10:00 pm, Jenny M wrote:
> I guess my question is also, was there any easier way to do it?? Is that how
> it's normally done?
>
It's not clear exactly what you're referring to.
Do you mean, is the typical pattern that which you described earlier, namely:
> I've been setting it using key-value coding: [object setValue:mySet
> forKey:categories]
>
No, that's not how the documentation recommends that you do it.
"Core Data automatically generates efficient public and primitive get and setaccessor methods for modeled properties (attributes and relationships) of managed object classes (see “Managed Object Accessor Methods”). When you access or modify properties of a managed object, you should use these methods directly."
[...]
"Typically, however, you do not want to set an entire relationship, instead you want to add or remove a single element at a time. To do this, you should use mutableSetValueForKey: or one of the automatically-generated relationship mutator methods (see “Dynamically-Generated Accessor Methods”):"
mmalc
_______________________________________________
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