开发者

NSTreeNode parentNode method never returns nil

开发者 https://www.devze.com 2023-01-14 08:25 出处:网络
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 ret

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             {...} 
> _childNodes开发者_如何学JAVAProxy     0x0 
> _representedObject   0x10019f500 
> _observationInfo     0x0 
> _reserved2           0x0 
> _childNodes          0x1020b6d10 
> _parentNode          0x0 
> _NSTreeNodeFlags     {...}
0

精彩评论

暂无评论...
验证码 换一张
取 消