Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

VolceOntra

macrumors 6502
Original poster
Apr 25, 2007
342
124
I'm having issues understanding the logic here.

What I'm basically trying to do is upon pressing a certain cell, I add information to that cell. Say a text label or a subview. That works fine.

What i'm not understanding is that when the cells are being dequeued by scrolling up or down, how do I retrieve that information for that cell when it reappears?

My understanding is that prototype cells never return (cell == nil).... So I'm confused.

Any help would be greatly appreciated! I'm somewhat new to this so sorry if this sounds totally moronic.
 
Last edited:
The cells are for displaying information, not for storage. Store your data in an ordered array and refer to that when fetching the information for any use, such as displaying into cells, using for calculation, or writing to a file.

When a cell gets dequeued, upon reuse it may be used for a difference row in a table view. That means there are attributes that need rebuilding. Anything that is unique to a row needs to be reset. Typically text, and sometimes a graphic like say a thumbnail.

I haven't done much with prototype cells. When using a prototype cell, your receiving a cell that has some pre-exsisting setup, just like a previously dequeued cell. Again, the unique data items for that cell need to filled in before you display it.
 
Thank you for the reply, that's actually what I was thinking was the case but it seemed a bit complicated to create an array and then compare it about.

So if I have the list in a NSMutableArray called queuedItemsList, once the app is going through the code:

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

is when I would compare whats in that array and if certain conditions are met, I can configure it as I please. Does that sound right?

Would adding the index path of the cell that is selected to that area be the most idea way? Also, how would you actually see if a certain cell exists in that area?

Any help would be greatly appreciated, I've been spending hours on stackoverflow and this forum trying to figure it out from previous posts. Thank you in advance.
 
Last edited by a moderator:
If your table has a single section then it's modeled as an array of dictionaries. Each dictionary represents a row. If your row has in it a "title" and an "image" then you add these to each row dictionary.

Then the number of rows in your table view is self.dataList.count. The row dictionary for a particular row is [self.dataList objectAtIndex:row] And the title for a row is [rowDictionary objectForKey:kTitleKey] If the rows are editable then use a mutableDictionary.

This is not complicated. This is the way it's done.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.