I am building an RSS reader with a GUI very similar to the built-in mail app. It uses Core Data to store the information once it is downloaded. When a story is downloaded, it has a blue dot to indicate it is new. Once I go back to the main page after reading a story the dot should be gone. It stays there until I scroll or relaunch the app. In the viewWillAppear method, I call [self.tableView reloadData]; which successfully calls cellForRowAtIndexPath for all visible cells. Here is my cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StoryCellIdentifier";
StoryCell *cell = (StoryCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"StoryCell" owner:self options:nil] objectAtIndex:0];
}
NSUInteger thisRow = [indexPath row];
NSManagedObject *managedObject = [storyData objectAtIndex:thisRow];
cell.titleLabel.text = [[managedObject valueForKey:@"title"] description];
cell.descLabel.text = [[managedObject valueForKey:@"subTitle"] description];
if (!([managedObject valueForKey:@"new"]))
{
cell.readIndicator.image = nil;
}
return cell;
}
The program hits the cell.readIndicator.image = nil; line when it should. In fact, the program follows the same execution path both when the dot is and is not there. Also, this is probably related, but when I click back on the Navigation Controller, the cell I had clicked on is still highlighted.
EDIT:The .m file that corresponds to the .xib is just boilerplate.
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier])
{ }
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
}
EDIT2:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
StoryView *storyView = [[StoryView alloc] initWithNibName:@"StoryView" bundle:nil];
NewsItem *item = [storyData objectAtIndex:[indexPath row]];
[storyView viewLoaded:item];
// Pass the selected object to the new view controller.
// ...
item.new = NO;
[managedObjectContext save:nil];
[self.navigationController pushViewController:storyView animated:YES];
[storyView release];
}