Skip to content

Instantly share code, notes, and snippets.

@nicholas
Created January 1, 2014 02:39
Show Gist options
  • Save nicholas/8204416 to your computer and use it in GitHub Desktop.
Save nicholas/8204416 to your computer and use it in GitHub Desktop.
# 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