Graphics Programs Reference
In-Depth Information
{
void (^completionBlock)(RSSChannel *obj, NSError *err) =
^(RSSChannel *obj, NSError *err) {
// When the request completes, this block will be called.
if (!err) {
// If everything went ok, grab the channel object and
// reload the table.
channel = obj;
[[self tableView] reloadData];
} else {
// If things went bad, show an alert view
NSString *errorString = [NSString stringWithFormat:@"Fetch failed: %@",
[err localizedDescription]];
// Create and show an alert view with this error displayed
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error"
message:errorString
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[av show];
}
};
// Initiate the request...
if (rssType == ListViewControllerRSSTypeBNR)
[[BNRFeedStore sharedStore] fetchRSSFeedWithCompletion:completionBlock];
else if (rssType == ListViewControllerRSSTypeApple)
[[BNRFeedStore sharedStore] fetchTopSongs:10
withCompletion:completionBlock];
}
Build and run the application. When the application launches, the BNR forums feed will
load as the default. Tap the Apple item in the segmented control, and the top ten songs on
iTunes will appear. Simple stuff, huh? (Tapping on a row while looking at Apple's RSS
feed won't show anything in the detail view controller, but you will fix this in the next
section.)
Search WWH ::




Custom Search