I have a core data model with a parent item and child items under it. In Xcode 3, when I generated the NSManagedObjects for this, I had methods called addChildsObject object method on Parent, but this has gone away in Xcode 4 (see Xcode4: Different code generated for custom core data managed objects). My question is this: how should I be adding the children to the parent now? I really don't want to mess with the generated code, revert to using Xcode3, or add a category to Parent to bring back the missing methods. Is there an approved way, or did Apple just muck up the whole process?
Asked
Active
Viewed 800 times
1 Answers
2
After discovering and reviewing the documentation on Dynamically-Generated Accessor Methods, it appears that Apple still recommends using the now non-existent methods, so it would appear that they have just screwed up by removing them. There is, however, another recommended way of doing this:
NSMutableSet *children = [parent mutableSetValueForKey:@"child"];
[children addObject: child1];
[children removeObject: child2];
This is not fabulous, because it relies on an unchecked string name, but it's the only remaining recommended way to do this without custom implementations. Thanks a lot Apple!

Micah Hainline
- 14,367
- 9
- 52
- 85