The problem is, I don't know how to determine to which row that newly-added object corresponds in the table view. Is there any way? I suppose it's the current-selected row, since it's set up to select on add. Is there a more elegant way to find out, though (i.e., what if adding didn't change the selection).

How does one find the row in the table view corresponding to any given instance?


Add this to your category on NSTreeController. It calls the - flattendedNodes method I gave you earlier. You can then get the tree node for the whatever you added to the tree and call NSOutlineView's - rowForItem:

- (NSTreeNode *)treeNodeForObject:(id)object;
{       
        NSTreeNode *treeNode = nil;
        for (NSTreeNode *node in [self flattenedNodes]) {
                if ([node representedObject] == object) {
                        treeNode = node;
                        break;
                }
        }
        return treeNode;
}

For those searching the archives, the previous code examples are in this thread:

http://lists.apple.com/archives/cocoa-dev//2008/May/msg03138.html

Jon

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to