Graphics Programs Reference
In-Depth Information
[NSKeyedArchiver archiveRootObject:cachedChannel toFile:cachePath];
[channelCopy addItemsFromChannel:obj];
[NSKeyedArchiver archiveRootObject:channelCopy toFile:cachePath];
}
block(cachedChannel, err);
block(channelCopy, err);
}];
We can now update ListViewController . In ListViewController.m , replace
the block that is passed to fetchRSSFeedWithCompletion: in fetchEntries .
if (rssType == ListViewControllerRSSTypeBNR) {
channel = [[BNRFeedStore sharedStore]
fetchRSSFeedWithCompletion:completionBlock];
channel = [[BNRFeedStore sharedStore] fetchRSSFeedWithCompletion:
^(RSSChannel *obj, NSError *err) {
// Replace the activity indicator.
[[self navigationItem] setTitleView:currentTitleView];
if (!err) {
// How many items are there currently?
int currentItemCount = [[channel items] count];
// Set our channel to the merged one
channel = obj;
// How many items are there now?
int newItemCount = [[channel items] count];
// For each new item, insert a new row. The data source
// will take care of the rest.
int itemDelta = newItemCount - currentItemCount;
if (itemDelta > 0) {
NSMutableArray *rows = [NSMutableArray array];
for (int i = 0; i < itemDelta; i++) {
NSIndexPath *ip = [NSIndexPath indexPathForRow:i
inSection:0];
[rows addObject:ip];
}
[[self tableView] insertRowsAtIndexPaths:rows
withRowAnimation:UITableViewRowAnimationTop];
}
}
}];
[[self tableView] reloadData];
} else if(rssType == ListViewControllerRSSTypeApple)
[[BNRFeedStore sharedStore] fetchTopSongs:10 withCompletion:completionBlock];
When the ListViewController makes a request, it will get back its cached copy as
usual and update its table. When the request finishes, it will get the merged channel. It can
count the number of items in each channel and determine how many new rows to add to
the table view, animating each one in.
 
Search WWH ::




Custom Search