I am getting this error “Application tried to present a nil modal view controller on target .”
This is the code I have and I am trying to setup if condition is meet, it will change initial view controller.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launchOptions
{
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"logged_in"]) {
ViewControllerOne *vc1 = [[ViewControllerOne alloc]init];
vc1=[self.storyboard instantiateViewControllerWithIdentifier: @"vc1"];
[self presentViewController:vc1 animated:YES completion:Nil];
} else {
ViewControllerTwo *vc2 = [[ViewControllerTwo alloc]init];
vc2=[self.storyboard instantiateViewControllerWithIdentifier: @"vc2"];
[self presentViewController:vc2 animated:YES completion:Nil];
}
// Override point for customization after application launch.
return YES;
}
What I use is, I think you are missing the
UIWindow:Then you can replace:
with: