Joetjah Joetjah - 18 days ago 7
Objective-C Question

TableView cells with double values

I've got a tableView, with custom cells being filled by NSMutableDictionaries, inside an NSMutableArray.

Now, I'd like to check the

valueForKey@"Location"
for the cell above the one currently being filled. Because, if that location is the same, that cell below should leave some labels blanco.

For example:

[Thing on location: Building A has problem X]
[ and problem Y ]
[Thing on location: Building B has problem X]


(Yes I know, a poor 'drawing' of a table, haha).

Anyway, in
cellForRowAtIndexPath
I've tried the code:

if ((indexPath.row - 1) > -1)
{
NSString *eerste = [[NSString alloc] initWithFormat:@"%@", [[lijstErrors objectAtIndex:(indexPath.row - 1)] objectForKey:@"Location"]];
NSString *tweede = [[NSString alloc] initWithFormat:@"%@", [incInRow objectForKey:@"Location"]];
NSLog(@"Comparing %@ met %@", eerste, tweede);
}


The problem is, it never gets called. My guess is,
cellForRowAtIndexPath
isn't called for every time a cell is filled in? Any hints on that?

Answer

No it's called every time a cell is drawn. Set the delegate of the tableView to your instance which hosts the tableview: in most cases it's self.