Graphics Programs Reference
In-Depth Information
[req setPredicate:pred];
// If there is at least one Link, then this item has been read before
NSArray *entries = [context executeFetchRequest:req error:nil];
if ([entries count] > 0)
return YES;
// If Core Data has never seen this link, then it hasn't been read
return NO;
}
You can build and run now, and the application will work. However, the
ListViewController does not yet use these methods to update its user interface or
tell the store when an item has been read. In ListViewController.m , add code to
the end of tableView:didSelectRowAtIndexPath: to mark an item as read
when a row is tapped.
RSSItem *entry = [[channel items] objectAtIndex:[indexPath row]];
[[BNRFeedStore sharedStore] markItemAsRead:entry];
// Immediately add a checkmark to this row
[[[self tableView] cellForRowAtIndexPath:indexPath]
setAccessoryType:UITableViewCellAccessoryCheckmark];
[webViewController listViewController:self handleObject:entry];
}
Then, modify tableView:cellForRowAtIndexPath: in ListViewControl-
ler.m to put a checkmark on each row whose RSSItem has been read.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"UITableViewCell"];
}
RSSItem *item = [[channel items] objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[item title]];
if ([[BNRFeedStore sharedStore] hasItemBeenRead:item]) {
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
} else {
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
return cell;
}
Search WWH ::




Custom Search