tags:

views:

25

answers:

0

Hello, I am using bindings with a NSOutlineView and NSTreeController. I am trying to determine the parent node of a particular node by using the -parentNode method of NSTreeNode, however the method never returns nil as indicated in the documentation. Instead I have to do this in order to make things work. The introspection is a hack. Any suggestions? Thanks.

NSTreeNode *parentNode = [[[treeController selectedNodes] objectAtIndex:0] parentNode];
LXNode *realParentNode = [parentNode representedObject];

if (parentNode && [realParentNode isKindOfClass:[LXNode class]])
{
    //The parent exists

}
else
{
   //Parent does not exist.
}

In debugger shows parentNode as follows

> parentNode           0x001a1e50 
> NSObject             {...} 
> _childNodesProxy     0x0 
> _representedObject   0x10019f500 
> _observationInfo     0x0 
> _reserved2           0x0 
> _childNodes          0x1020b6d10 
> _parentNode          0x0 
> _NSTreeNodeFlags     {...}