Search code examples
objective-ciosnsuserdefaultspushviewcontroller

How to show pushviewcontroller on first application launch?


I'm checking with NSUserDefault if it is the first time app is loaded. If is the first time I must push a viewcontroller to a specific view. I do the same action and it works, but the first time app load don't.

Here's my code:

SettingsViewController *viewSet = [[SettingsViewController alloc] 
                                   initWithNibName:@"SettingsViewController" 
                                   bundle:[NSBundle mainBundle]];
self.settingViewController = viewSet;
[viewSet release];
[[self navigationController] pushViewController:self.settingViewController animated:YES];   
settingViewController.title =@"Impostazioni";

I receive a sigkill some instruction after pushing the viewController.

Maybe the problem is that it's in viewDidAppear? I must check there because if is not the first time I must load some other userdefaults values.

EDIT:

I've found the trouble (some bad values passed at NSUserDefaults). Now my controller is pushed but I don't see any button to pop of this viewcontroller....


Solution

  • Are you trying to push a different view the first time your app starts?

    What is the problem? The code above will push a 'SettingViewController' onto the navigation stack when run.