Man, I'm feeling dumb today...NSOutlineView/NSTreeController is kicking my butt...

I'm trying to determine a sane new selection for when I delete the currently selected item in an NSOutlineView.

I'm failing.

My thought was to get the index path of the item I deleted, then try to select that same index path, thinking that that would now be the "next" sibling if there was one, and the selection method would return NO if there was no "next" sibling (since the index path would be invalid).

However, if I've just deleted the "last" sibling (and thus there is not "next" sibling), the selection method (-setSelectionIndexPath:) actually returns YES, because instead of *not* changing the selection because the index path is invalid, it changes the selection to nothing because the index path is invalid (thus necessitating the YES return value).

If there was no "next" sibling, I was going to try to select the "previous" sibling, if there was one, and only if there wasn't, then proceed to select the deleted item's parent (if there was one). But I can't get this far, because of the "problem" described in the previous paragraph.

So, it seems like I need to try to get the actual *object* pointed to by the index path and see if there is a valid object there, but I can't figure out how to do that, either from the NSOutlineView or its backing NSTreeController.

Any ideas?


Thanks!
randy
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to