Nerdfeed App Crashes



I followed the steps to create the Nerdfeed RSS Reader App
but I get several compiler warnings and app crashes when I
click on a feed to get the UIWebView loaded.

Hope you can help.

Compiler warnings:

Instance method ‘-setView:’ not found (return type defaults to ‘id’)
Instance method ‘-view’ not found (return type defaults to ‘id’)

Incompatible pointer types sending ‘WebViewController *’ to parameter of type ‘UIViewController *’
‘WebViewController’ may not respond to ‘navigationItem’

My code:

[code]#import “WebViewController.h”

@implementation WebViewController

  • (void)loadView
    // Create an instance of UIWebView as large as the screen
    CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];
    UIWebView *wv = [[UIWebView alloc] initWithFrame:screenFrame];
    // Tell web view to scale web content to fit within bounds of webview
    [wv setScalesPageToFit:YES];

    [self setView:wv];
    [wv release];

  • (UIWebView *)webView
    return (UIWebView *)[self view];


[code]#import “ListViewController.h”
#import “RSSChannel.h”
#import “RSSItem.h”
#import “WebViewController.h”

@implementation ListViewController
@synthesize webViewController;

  • (id)initWithStyle:(UITableViewStyle)style
    self = [super initWithStyle:style];

    if (self) {
    [self fetchEntries];

    return self;

  • (NSInteger)tableView:(UITableView *)tableView
    return [[channel items] count];

  • (UITableViewCell *)tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath
    UITableViewCell *cell = [tableView
    if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
    RSSItem *item = [[channel items] objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[item title]];

    return cell;

  • (void)tableView:(UITableView *)tableView
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    // Push the web view controller onto the navigation stack - this implicitly
    // creates the web view controller’s view the first time through
    [[self navigationController] pushViewController:webViewController animated:YES];

    // Grab the selected item
    RSSItem *entry = [[channel items] objectAtIndex:[indexPath row]];

    // Construct a URL with the link string of the item
    NSURL *url = [NSURL URLWithString:[entry link]];

    // Construct a request object with that URL
    NSURLRequest *req = [NSURLRequest requestWithURL:url];

    // Load the request into the web view
    [[webViewController webView] loadRequest:req];

    // Set the title of the web view controller’s navigation item
    [[webViewController navigationItem] setTitle:[entry title]];

  • (void)fetchEntries
    // Create a new data container for the stuff that comes back from the service
    [xmlData release];
    xmlData = [[NSMutableData alloc] init];

    // Construct a URL that will ask the service for what you want -
    // note we can concatenate literal strings together on multiple
    // lines in this way - this results in a single NSString instance
    NSURL *url = [NSURL URLWithString:

    // For Apple’s Hot News feed, replace the line above with
    // NSURL *url = [NSURL URLWithString:@“”];

    // Put that URL into an NSURLRequest
    NSURLRequest *req = [NSURLRequest requestWithURL:url];

    // Create a connection that will exchange this request for data from the URL
    connection = [[NSURLConnection alloc] initWithRequest:req

// This method will be called several times as the data arrives

  • (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data
    // Add the incoming chunk of data to the container we are keeping
    // The data always comes in the correct order
    [xmlData appendData:data];

  • (void)connectionDidFinishLoading:(NSURLConnection *)conn
    // Create the parser object with the data received from the web service
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:xmlData];

    // Give it a delegate
    [parser setDelegate:self];

    // Tell it to start parsing - the document will be parsed and
    // the delegate of NSXMLParser will get all of its delegate messages
    // sent to it before this line finishes execution - it is blocking
    [parser parse];

    // The parser is done (it blocks until done), you can release it immediately
    [parser release];

    // Get rid of the XML data as we no longer need it
    [xmlData release];
    xmlData = nil;

    // Get rid of the connection, no longer need it
    [connection release];
    connection = nil;

    [[self tableView] reloadData];
    NSLog(@"%@\n %@\n %@\n", channel, [channel title], [channel shortDescription]);

  • (void)connection:(NSURLConnection *)conn
    didFailWithError:(NSError *)error
    // Release the connection object, we’re done with it
    [connection release];
    connection = nil;

    // Release the xmlData object, we’re done with it
    [xmlData release];
    xmlData = nil;

    // Grab the description of the error object passed to us
    NSString *errorString = [NSString stringWithFormat:@“Fetch failed: %@”,
    [error localizedDescription]];

    // Create and show an alert view with this error displayed
    UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error"
    [av show];
    [av autorelease];

  • (void)parser:(NSXMLParser *)parser
    didStartElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qualifiedName
    attributes:(NSDictionary *)attributeDict
    NSLog(@"%@ found a %@ element", self, elementName);
    if ([elementName isEqual:@“channel”]) {

      // If the parser saw a channel, create new instance, store in our ivar
      [channel release];
      channel = [[RSSChannel alloc] init]; 
      // Give the channel object a pointer back to ourselves for later 
      [channel setParentParserDelegate:self];
      // Set the parser's delegate to the channel object
      [parser setDelegate:channel];