如何在第一次启动应用时显示消息?
问题描述:
是否有一种简单的方法可以在第一次启动应用时显示警报,或者我是否必须通过制作BOOL并在第一次运行后将其设置为FALSE来手动执行此操作?
Is there an easy way to have an alert appear only the first time an app is launched, or will I have to do it manually by making a BOOL and having it set to FALSE after it's run the first time?
答
听起来很容易......
Sounds easy enough...
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if(![defaults boolForKey:@"hasBeenLaunchedBefore"]) {
//Show alert
[defaults setBool:YES forKey:@"hasBeenLaunchedBefore"];
[defaults synchronize];
}