我有一个故事板和导航控制器的应用程序,我想如果用户启动应用程序第一时间弹出一个协议视图,在Appdelegate.m反向问号布尔值NSUserDefaults的IOS
- (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
了我第一次拿到reverse question mark sign
,我想这既不设置为yes或no
所以,我怎么能设置一个布尔值,它保存在iOS设备,并调用它每次应用程序启动?