• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reusable Cells
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reusable Cells


  • Subject: Re: Reusable Cells
  • From: Conrad Shultz <email@hidden>
  • Date: Wed, 2 Feb 2011 20:34:48 -0800

On Feb 2, 2011, at 2:42, JD Guzman <email@hidden> wrote:

> Hello,
>
> I'm new to this list and also relatively new to development on the Mac/iPhone platforms.

Welcome!

> I was just wondering if someone could clarify how exactly dequeueReusableCellWithIdentifier: works. The reason I ask is because I have the following code:
>
> ---------
>
> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
>
>    UITableViewCell *cell = [channelList dequeueReusableCellWithIdentifier:@"channelCell"];
>
>    if (cell == nil) {
>        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"channelCell"] autorelease];
>    }
>
>    [[cell textLabel] setText:[channels objectAtIndex:[indexPath row]]];
>
>    return cell;
> }
>
> ---------
>
> Now if I set a break point inside the if statement I was expecting that it would only be entered once, however it is entered every time a cell is created.  Shouldn't the call to dequeueReusableCellWithIdentifier: return a cell after it has been created inside the if statement?  Or am I misunderstanding how this works?

What is channelList? Is it just tableView?

Other than that, at first glance this looks ok. Are you sure you are getting a new cell EVERY time? What I mean is: the UITableView will create a pool of cells that covers the visible range of the table, and keep a few around that hang off the ends of the table to help with scrolling performance. I would expect, depending on your row height, etc, for you to break maybe a dozen times before you start seeing cell reuse as you scroll.

Apologies for any mistakes; sent from my iPad as they say.

--
Conrad Shultz
www.synthetiqsolutions.com
_______________________________________________

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

References: 
 >Reusable Cells (From: JD Guzman <email@hidden>)

  • Prev by Date: Re: Reusable Cells
  • Next by Date: NSViewWidthSizable causing problems?
  • Previous by thread: Re: Reusable Cells
  • Next by thread: Which is the lightest way to draw images and text?
  • Index(es):
    • Date
    • Thread