NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"username"] == nil)
{
//Load Login View if no username is found
NSLog(@"No username found");
self.nameLoginView=[[NewLoginViewController alloc]initWithNibName:@"NewLoginViewController" bundle:nil];
[self.navigationController pushViewController:self.nameLoginView animated:YES];
}
else
{
NSString *savedUsername = [defaults stringForKey:@"username"];
NSLog(@"Username found: %@", savedUsername);
self.mainView = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
[self.navigationController pushViewController:self.mainView animated:YES];
}
I mean if he is logging for first time in our app he has to go to newLoginView Controller and if user is logging for second time he has to go to another view controller? i am doing this code in view controller itself?