Re: NSTreeController - setEntityName only settable once??
Re: NSTreeController - setEntityName only settable once??
- Subject: Re: NSTreeController - setEntityName only settable once??
- From: email@hidden
- Date: Tue, 31 Jan 2006 00:55:07 -0800
mmalcolm crawford wrote:
On Jan 29, 2006, at 4:12 PM, Andre wrote:
- (IBAction)addAttribute:(id)sender
{
id newAttribute = [[self managedObjectContext]
insertNewEntityWithName:@"Attribute"];
[self insertObject:newAttribute atArrangedObjectIndexPath:[self
selectionIndexPath]];
}
This just adds peers...
That's because you're telling it to add a peer.
The only problem now, is, how to add children....
<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSTreeController.html#//
apple_ref/occ/instm/NSTreeController/addChild:>
Or if you need something more sophisticated, follow the pattern
Scott suggested and implement your desired behaviour in code
(create a new instance of the necessary entity and add it to the
appropriate relationship of the currently-selected object).
Just to update, and bring this to a close. Adding to the currently
selected object causes NSBrowser to loose track of the selection.
So its best to insert using the current selection index path, and add
an index path with 0 as the argument.
It didn't work for me originally because my children accessor was not
done properly.
For those using NSTree/Array controllers, make sure to add a set<Key>:
(NSSet*)<keys> style method in addition to the 5 coredata ones
mentioned in the docs.
Then things start to function normally if your doing non-modeled stuff.
Bye!
Andre
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden