You can either use NSUserDefaults to store the app's login state as stated by the others. The value will stay as is until the app is deleted. i.e. even when you kill the app or restart the device, if the last value was 'logged in'.
If you want to 'reset' the user's state when the app is killed or device is restarted, then another approache is to make your User's object as a singleton. When app is killed or device is restarted, unlike the NSUserDefault, the user's state will be reset (as the object no longer exists) and user will need to login again. Using this method: http://lukeredpath.co.uk/blog/a-note-on-objective-c-singletons.html to create singleton of your user's object
+ (id)sharedInstance
{
static dispatch_once_t pred = 0;
__strong static id _sharedObject = nil;
dispatch_once(&pred, ^{
_sharedObject = [[self alloc] init]; // or some other init method
});
return _sharedObject;
}
Add the above to your User's class and then you can then add the appropriate properties related to the user's state, e.g BOOL isLoggedOn, and then you can access this along the line:
BOOL isLoggedIn = [[User sharedInstance] isLoggedIn];