我有一个带有故事板和导航控制器的应用程序,如果用户第一次启动该应用程序,我想弹出一个协议视图,
在 Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//app launched first time
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setBool:YES forKey:@"firstTime"];
BOOL firstTime = [prefs boolForKey:@"firstTime"];
NSLog(@"firstTime %c",firstTime);
//check if user has agreed agreement or not
if ( firstTime==YES) {
//replace and push rootview manually
UIStoryboard *storyboard = [UIApplication sharedApplication].delegate.window.rootViewController.storyboard;
UIViewController *loginController = [storyboard instantiateViewControllerWithIdentifier:@"AgreementViewController"];
[self.window.rootViewController presentModalViewController:loginController animated:YES];
return NO;
}else
return YES;
}
在Nslog
我第一次得到 areverse question mark sign
时,我想它既没有设置为 yes 也没有设置为 no
那么如何设置布尔值,将其保存在 ios 设备中并在每次应用启动时调用它?