Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zachsilvey

macrumors 6502
Original poster
Feb 5, 2008
444
3
Battle Ground
In *AppDelegate.h I create a UINavigation Controller and make it a property

Code:
UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

then in *AppDelegate.m I use

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
	RootViewController *rootViewController = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:nil];
	navigationController = [[UINavigationController alloc]initWithRootViewController:rootViewController];

	[self.window addSubview:navigationController.view];
	
	[rootViewController release];
	
    [self.window makeKeyAndVisible];
    
    return YES;
}

Why is it in the RootViewController.m I can call this?

Code:
[self.navigationController pushViewController:secondLevelViewController animated:YES];

navigationController doesn't belong to that class so why is it that I can call "self.navigationController"?
 
Because all view controllers have a navigationController property (it's in the documentation). When you add a view controller to a navigation controller (either by pushing it or initing the navigation controller with a root view controller) it get's set by the navigation controller.
 
So it was just by chance that I named the UINavigationController "navigationController'?

I should spend more time in the documentation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.