Graphics Programs Reference
In-Depth Information
Now you can update
fetchEntries
in
ListViewController.m
to grab the chan-
nel from the return value of
fetchRSSFeedWithCompletion:
and update the table
right away.
if (rssType == ListViewControllerRSSTypeBNR)
{
channel = [[BNRFeedStore sharedStore]
fetchRSSFeedWithCompletion:completionBlock];
[[self tableView] reloadData];
}
else if (rssType == ListViewControllerRSSTypeApple)
[[BNRFeedStore sharedStore] fetchTopSongs:10 withCompletion:completionBlock];
Build and run the application and then load the
BNR
feed. Go to the forums and create a
new post. (You can create a test post in the forum for this chapter and delete it later.)
Then, switch to the
Apple
feed and back to the
BNR
feed to force a reload. You will no-
tice that your list remains intact, and after the activity indicator finishes spinning, your
post will appear at the top of the list!
Now this is all fine and dandy, but there is still a problem. Right now, the store returns an
instance of
RSSChannel
to the
ListViewController
immediately. In the store's
completion block, the other
RSSChannel
merges its
items
into the
very same
RSSChannel
that was returned to the
ListViewController
. This is bad. A store
shouldn't update values it has already given to a controller without at least informing the
controller of the changes and giving the controller the decision to act on those changes.
Case in point: there is no way for the
ListViewController
to know which items are