iOS: Use a boolean in NSUserDefaults

You can set your boolean by using:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"logged_in"];
[[NSUserDefaults standardUserDefaults] synchronize];

and read it by using this code:

if(![[NSUserDefaults standardUserDefaults] boolForKey:@"logged_in"]) {
    [self displayLogin];
} else {
    [self displayMainScreen];
}

There is a method in NSUserDefaults called registerDefaults:. You use this method to set your application's "default defaults." Basically, you create an NSDictionary containing your default keys and values (in your case a NO for a "saved credentials" key), and you register it using registerDefaults:. This if often done in app delegate's + (void)initialize method to ensure that your defaults are registered before they are needed. These values only get used if your app hasn't replaced them. In other words, they won't be used unless the key you're looking for isn't in the Application Domain, i.e., the user defaults read from the user's .plist file.

On the other hand, you could just check for login credentials and pop up an alert if they're missing. This eliminates the need to keep your boolean value synchronized with the login credentials. If you later provide a "delete login credentials" capability, you won't have to remember to set the boolean back to NO. If your login credentials are saved in user's defaults, you'd do this:

NSString *userID = [[NSUserDefaults standardUserDefaults] stringForKey:@"userID"];
NSString *password = [[NSUserDefaults standardUserDefaults] stringForKey:@"password"];
if (userID != nil && password != nil) {
    // Code to log user in
} else {
    // Code to pop up an alert
}