Crazy TableView (Or more likely me being just a jerk) ;-)
- by Miky Mike
Hi guy, I'm going crazy with all that objective C.
I went to bed at 1.30 pm today, spending the night on my app but I love it...
Well that's not the point anyway...
My question is ....
I have a table view which evaluates a statement when it displays its data : it goes like this :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
cell = ((MainCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]);
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MainCell" owner:self options:nil];
}
Entry *entry = [fetchedResultsController objectAtIndexPath:indexPath];
cell.topLabel.text = [@"* " stringByAppendingString: entry.entryname];
cell.bottomLabel.text = entry.textbody;
if ([entry.active boolValue] == YES) {
cell.cellImageView.image = [UIImage imageNamed:@"check.png"];
}
else {
cell.cellImageView.image = nil;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
return cell;
}
The problem is that the first time it displays the data, the conditions are met when I scroll down the tableview but when I scroll up, sometimes, I get my "check.png" image and the accessory as well, which is not possible normally.
Am I going crazy or is it the tableview ?
Could you help me with that please, I can't figure out why it doesn't work... :-((
Thanks a lot in advance.
Mike