I'm totally baffled why this is not working. I'm trying to insert a new NSTreeNode into a mutable array of child nodes. Here's the code:
NSTreeNode *newNode = [[NSTreeNode alloc] init];
NSMutableArray *children = [anExistingParentTreeNode mutableChildNodes];
[children addObject:newNode];
Upon execution I get all sorts of errors:
- -[NSCFSet initWithObjects:count:]: attempt to insert nil object at objects[0]
- -[NSTreeNode _tearDownObserving]: unrecognized selector sent to instance 0x2000bff40
- Serious application error. Exception was caught during Core Data change processing: -[NSTreeNode _tearDownObserving]: unrecognized selector sent to instance 0x2000bff40 with userInfo (null)
The errors seem to be dealing with KVO stuff. Has anybody encountered errors like these using mutableChildNodes? Any help is greatly appreciated.
Note: The underlying NSTreeController IS bound to core data via managed object context.