I noticed that my subclass os NSTreeController runs newObject
only when the add:
method is called but never for addChild:
I found this thread discussing the very same issue. Though in this case the user is using the tree controller in Core Data mode, however I have mine set to use a specific Class (object mode).
What reason could there be for addChild:
not using the newObject
method?
If newObject
gets called for add:
I see no reason why it shouldn't work for addChild:
. I confirmed this behavior in Apple's SourceView demo app by replacing OutlineController with a subclass, and connecting buttons to add:
and addChild:
- again only add:
calls newObject
. I find this really really really weird behavior.
It depends on context. If the
NSTreeController
is talking to Plain Old Objects, it will run-newObject
in the context of-addChild
, because given the known-objectClass
, the tree controller has all the information it needs in order to put everything in the right place.If
NSTreeController
is talking to anNSManagedObjectContext,
it will not run-newObject
, because the-newObject
implementation won't have enough context to establish the relationship with the selection, and the relationship must be in place once-addChild:
is finished.