FROM : Jonathan Dann
DATE : Sat May 31 22:35:16 2008
>
> 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
DATE : Sat May 31 22:35:16 2008
>
> 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
| Related mails | Author | Date |
|---|---|---|
| Rick Mann | May 31, 10:27 | |
| I. Savant | May 31, 16:34 | |
| Rick Mann | May 31, 22:21 | |
| I. Savant | May 31, 22:31 | |
| Jonathan Dann | May 31, 22:35 | |
| Rick Mann | May 31, 22:35 | |
| Rick Mann | May 31, 23:39 | |
| Rick Mann | Jun 4, 05:15 | |
| Rick Mann | Jun 4, 05:22 |






Cocoa mail archive

