The popular solution is to use [Nsuserdefaults standarduserdefaults a key in most places, if it doesn't exist, which means that this is the Application launcher, otherwise it's not the first time
In APPDELEGATE.M, locate the "Application:didfinishlaunchingwithoptions:" Method and add the following code:
if
(![[NSUserDefaults standardUserDefaults] boolForKey:@
"everLaunched"
]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@
"everLaunched"
];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@
"firstLaunch"
];
}
else
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@
"firstLaunch"
];
}
总的解决办法是 2 个key: @”everLaunched”判断用户以前是否登录,
@”firstLaunch” 用来开发者在程序的其他部分判断.
在第一次启动的时候 key @”everLaunched” 不会被赋址的, 并且设置为YES. @”firstLaunch” 被设置为 YES.
在程序的其他部分用以下代码判断:
if
([[NSUserDefaults standardUserDefaults] boolForKey:@
"firstLaunch"
]) {
// 这里判断是否第一次
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@
"第一次"
message:@
"进入App"
delegate:self
cancelButtonTitle:@
"我知道了"
otherButtonTitles:nil];
[alert show];
[alert release];
}
The first piece of code runs key @ "Firstlaunch" will be set to NO
Determine the first time iOS app starts someone else's hey