Switch between 2 views.

Discussion in 'iOS Programming' started by Depress, Jun 24, 2009.

  1. Depress macrumors newbie

    Jun 22, 2009

    Like the title says, i want to switch from view 1 to view 2.
    So i started searching and came up with this:
    		ViewControllerStats *newViewController = [[ViewControllerStats alloc] initWithNibName: @"Statistics" bundle:nil];
    		IceStatsAppDelegate *appDelegate = (IceStatsAppDelegate *)[[UIApplication sharedApplication] delegate];
    		[self.view removeFromSuperview];
    		[[appDelegate window] addSubview: [newViewController view]];
    This code is located in the view controller of the first view. From this view i want to go to the second view(ViewControllerStats is its UIViewController).

    When i try to debug it crashes on the point of the last code line.
    The console gives me this line of code:
     Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewControllerStats 0xf4c400> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key delegate.
    Because this is a learning cycle for me i got no clue what to do next to fix this.


Share This Page