On Jul 3, 2009, at 2:45 PM, Brian Slick wrote:

So now I either need to figure out how to make my scenarios all work with a single identifier, or I may just go ahead with the code-only cell I just built in response to the performance issue. If would be nice if there was some kind of queueWithReuseIdentifier: method for these XIB cases.

Oh, you can have as many identifiers as you want.
For a nib-based approach, simply have as many nib files as you want -- where each nib file has a single cell but a different identifier -- and you probably(*) have an outlet for each type.


// Caveat: Typed in Mail
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        if (condition1) {
                static NSString *CellType1Identifier = @"CellType1Identifier";

CellType1 *cell = (CellType1 *)[tableView dequeueReusableCellWithIdentifier:CellType1Identifier];
                if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CellType1" owner:self options:nil];
                cell = cellType1;
                self. cellType1 = nil;
                // configure cell ...
                return cell;
        }

        if (condition2) {
                static NSString *CellType12dentifier = @"CellType12dentifier";

CellType1 *cell = (CellType1 *)[tableView dequeueReusableCellWithIdentifier:CellType2Identifier];
                if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CellType2" owner:self options:nil];
                cell = cellType2;
                self. cellType2 = nil;
                // configure cell ...
                return cell;
        }

        // ...


(*) You wouldn't actually *need* a different outlet for each type, since the outlet is used only very briefly for each load, and each load happens sequentially, but you may prefer to identify each type nevertheless.


Incidentally, that's what is wrong with TaggedLocations... it also does not have the identifier in the XIB. I manually added it, then retested, and saw dramatically better performance (for my own program, too).
[...]
All this aside, please file a performance bug against the TaggedLocations sample.
Done, although I'm not sure if I did so correctly. Thank you for your help.


Ah, thanks.
If you could send the bug number, that would be useful.

mmalc

_______________________________________________

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