I am working over a simple application for iOS in Xcode 5.1.1.
I am a newbie in Xcode and Objective-C, so I have a little problem.
This is what I have:
Idea of my application is very simple - when user launch application first time, he see Authorization form. When he enter his Login and Password and press Sign In, my application make request to server, and if everything is ok - login and password are correct - application save user login:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:self.txtUsername.text forKey:@"SavedUserName"];
[defaults synchronize];
and opens view with "It's Ok!".
[self performSegueWithIdentifier:@"login_success" sender:self];
Authorization is work great, user login saving os works to. But now, when user launch app again I need to open view with "It's OK", if he already authorized:
- (void)viewDidLoad
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *authLogin = [defaults objectForKey:@"SavedUserName"];
if(![authLogin isEqualToString:@""]){
//I think here application must load view with "It's OK!", but how to do this?
//I tried to use here this - [self performSegueWithIdentifier:@"login_success" sender:self]; but it doesn't works.
}
}
Please, help me, how to solve my problem? P.S. I try to find answer on my question in Google and here on StackOverflow, but all that I find and try to use didn't help me.