Re: Table view data source methods order?
Re: Table view data source methods order?
- Subject: Re: Table view data source methods order?
- From: Quincey Morris <email@hidden>
- Date: Mon, 3 Aug 2009 11:27:12 -0700
On Aug 3, 2009, at 1:04 AM, Chase Meadors wrote:
I'm having a bit of trouble here with table view data source
methods. I have implemented. I have these three:
1) - (NSCell *)tableView:(NSTableView *)sender
dataCellForTableColumn:(NSTableColumn *)tableColumn row:
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn:
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex;
I think you're making a mistake in expecting an order to be guaranteed
amongst mixed data source and delegate methods. Whatever order you see
now isn't guaranteed and could change in the future.
Your #2 is correctly implemented, so forget about it from the point of
view of the delegate methods.
Since you only have one NSPopUpButtonCell, you don't need both #1 and
#3. And since you apparently do need #1, you can get rid of #3, as
Andy suggested.
Wherever you decide to set the menu for the current row, *that* method
should also set the selected item index in the menu. Then it doesn't
matter whether #2 is called before or after or at all. There's no
reason for the delegate method to rely on the data source method to do
its work for it.
You're not worrying about whether it's inefficient to recompute the
selected menu item index, are you? If so, you can be sure a posse is
going to be after you for "premature optimization". :)
_______________________________________________
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