I am trying to Display Selected ViewController based on user has Logged in inside the app or not.if user has logged in then it should display HomeViewController
, if not then it should display InitialViewController
.My Initial StoryBoard is MainStoryBoard
and LoginVC are in InitialStoryBoard
. Below is my sample code and struggling lot to fix this issue.can anybody help to fix this issue .
/- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions* /
BOOL isLoggedIn = [[NSUserDefaults standardUserDefaults]boolForKey:@"isLoggedIn"]; NSLog(isLoggedIn ? @"Yes" : @"No"); NSLog([[NSUserDefaults standardUserDefaults]boolForKey:@"isLoggedIn"] ? @"Yes" : @"No"); if (!isLoggedIn) { NSString *device2; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { device2 = @"InitialStoryboard_iPad"; } else { device2 = @"InitialStoryboard_iPhone"; } NSLog(@"device :%@",device2); UIStoryboard *storyboard2 = [UIStoryboard storyboardWithName:device2 bundle:nil]; InitialVC *initialController = [storyboard2 instantiateInitialViewController]; // [(UINavigationController *)self.window.rootViewController presentViewController:initialController animated:YES completion:nil]; // [(UINavigationController *)self.window.rootViewController pushViewController:initialController animated:NO]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = initialController; [self.window makeKeyAndVisible]; }
If Login is Successful then i am not able to dismissCurrentVC
as Initial is RootVC
.If login is Successful then it should make DismissVC if MainStoryBoard
is Initial Storyboard.or login Successful should make HomeVC
PresentVCModally if InitialStoryBoard
is InitialStoryboard.Hope you can understand my Issue.
Thanks in Advance