Re: NSOutlineView - Automatically select newly added item - Help needed
Re: NSOutlineView - Automatically select newly added item - Help needed
- Subject: Re: NSOutlineView - Automatically select newly added item - Help needed
- From: Mario Kušnjer <email@hidden>
- Date: Tue, 6 Oct 2009 17:41:30 +0200
Hi all !
Thanks for your replies everybody !
I have reviewed my code according to yours inputs and I found where
the problem was.
Here's the reviewed code:
if ([lsOutlineView selectedRow] < 0)
{
Parent *parent = [Parent new]; <--- create new Parent object
NSLog(@"1 - %@", parent);
[sourceListLevelZero addObject:parent]; <--- add newly created
Parent object to the root array
[lsOutlineView reloadItem:nil reloadChildren:YES]; <--- reload
outline view
NSUInteger index = [lsOutlineView rowForItem:parent]; <--- get the
row index of the newly created Parent object from the outline view
NSLog(@"2 - %i", index);
NSMutableIndexSet *indexSet = [NSMutableIndexSet new]; <--- create
new empty NSMutableIndexSet object
NSLog(@"3 - %@", indexSet);
[indexSet addIndex:index]; <--- add row index of the Parent object
to the indexSet
NSLog(@"4 - %@", indexSet);
[lsOutlineView expandItem:nil expandChildren:YES]; <--- expand the
root array objects and all of their children
[lsOutlineView selectRowIndexes:indexSet byExtendingSelection:NO];
<--- select row with index number from the indexSet without multiple
row selection
[parent release]; <--- release parent object
[indexSet release]; <--- release indexSet
}
I assume this is correct way now because it works fine.
If someone has some objections, please state your comment, I am
interested to hear (learn).
I will (when I make this code actually do something useful) post a
link to the list for the entire source code so anyone interested to
review it (and point out my mistakes) will
be most welcome.
Since I have no idea how to use Instruments (and until I do) this will
be very helpful to me in future learning.
Thanks again.
Bye !
Mario Kušnjer
email@hidden
+385957051982
mariokusnjer@skype
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden