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];
}
The total solution is 2 key: @ "everlaunched" to determine if the user has previously logged in,
@ "Firstlaunch" is used by developers to judge in other parts of the program.
At the first boot, key @ "everlaunched" is not assigned and is set to Yes. @ "Firstlaunch" is set to YES.
In other parts of the program, use the following code to determine:
if ([[Nsuserdefaults standarduserdefaults] Boolforkey: @firstLaunch]) {
Here to determine whether the first time
Uialertview *alert=[[uialertview Alloc] initwithtitle:@ first time
message:@ into the app
Delegate:self
cancelbuttontitle:@, I know.
Otherbuttontitles:nil];
[Alert show];
[Alert release];
}
The first piece of code running key @ "Firstlaunch" will be set to NO.
IOS Judging program starts for the first time