Created
January 1, 2014 02:39
-
-
Save nicholas/8204416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AppDelegate.m | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; | |
[[AuthenticationManager sharedInstance] setupWithWindow:self.window]; | |
return YES; | |
} | |
# AuthenticationManager.m | |
- (UIViewController *)loginViewController | |
{ | |
if (_loginViewController) return _loginViewController; | |
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LPiPhone" bundle:nil]; | |
_loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; | |
return _loginViewController; | |
} | |
- (void)setupWithWindow:(UIWindow *)window | |
{ | |
self.window = window; | |
if (![[SessionManager sharedInstance] loggedIn]) | |
[self showLoginScreen:NO]; | |
} | |
- (void)showLoginScreen:(BOOL)animated | |
{ | |
NSInteger transition = animated ? UIViewAnimationOptionTransitionFlipFromRight : UIViewAnimationOptionTransitionNone; | |
[UIView transitionWithView:self.window duration:0.5 options:transition|UIViewAnimationOptionAllowAnimatedContent animations:^{ | |
self.window.rootViewController = [self loginViewController]; | |
} completion:nil]; | |
} | |
# SessionManager.m | |
- (BOOL)loggedIn | |
{ | |
return [self.authenticationToken length] > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment