I'm doing an Twitter app, and on the AppDelegate -didFinishLaunchingWithOptions I'm using next code for loading the login view if NSUserDefaults on that object are empty:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *test = [prefs objectForKey:@"username"];
if (test == @"(null)" || test == nil) {
LoginScreenViewController *login = [[LoginScreenViewController alloc] initWithNibName:@"LoginScreenViewController" bundle:nil];
[self.window addSubview:login.view];
[self.window makeKeyAndVisible];
} else {
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
}
And I'm able to load the login view, but then how would I dismiss it? The login screen has to show up before the tabBarController is loaded, so when the Login controller is done, the tab bar controller gets started as if it wouldn't have any other view before. Thanks in advance!
if (test==nil)should be a sufficient test andtest==@"(null)"is a direct pointer comparison that will be false. If you want a null that is distinct from nil use[NSNull null]for assignment and comparison. - drawnonward