0

I am new to storyboards. I have made up an application that has a login screen. Once the user logs in, his username and password are saved in NSUserDefaults. This is because when the user has to login only once after installing the application. Whenever the user opens the application again, the login page should not appear. I dont know how to achieve this in storyboards. An someone please guide me how to do this?

EDIT:

I have written the following code in didFinishLaunchingWithOptions

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"username"] && [defaults objectForKey:@"password"] && [defaults objectForKey:@"url"]) {
    self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"navigationview"];
}
else {
    self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"login"];
}
return YES;
Alladinian
  • 34,483
  • 6
  • 89
  • 91
Hassan Zaheer
  • 1,361
  • 2
  • 20
  • 34
  • Possible duplicate: http://stackoverflow.com/questions/8451975/conditionally-start-at-different-places-in-storyboard-from-appdelegate – Alladinian Jun 14 '13 at 07:31
  • I get the following error: Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set? See Code in Question. – Hassan Zaheer Jun 14 '13 at 07:54
  • Make sure that you have set a controller as 'Initial View Controller' in your storyboard (it will show an arrow pointing to the scene). After that you'll be good to go. – Alladinian Jun 14 '13 at 08:07
  • You're welcome. I'm gonna mark it as duplicate since the linked answer was what you're looking for. – Alladinian Jun 14 '13 at 08:57

0 Answers0