Loading

Monday, June 14, 2010

Uses Of NSUserDefaults

THIS CODE WILL RUN THE APPLICATION 6 TIMES AND THEN SHOW THE MESSAGE


//[[NSUserDefaults standardUserDefaults] setObject:@"True" forKey:@"checkSelect"];
//if([[[NSUserDefaults standardUserDefaults] objectForKey:@"checkSelect"] isEqualToString:@"True"])
if([[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"]==0)
{
[[NSUserDefaults standardUserDefaults]setInteger:1 forKey:@"App_Testy_ICream_Counter"];
}
else if([[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"]<6)
{
int i=[[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"];
i++;
[[NSUserDefaults standardUserDefaults]setInteger:i forKey:@"App_Testy_ICream_Counter"];
}
else
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Sorry" message:@"We're glad you've enjoyed playing with Tasty Ice Cream! Please take the time to rate this app" delegate:self cancelButtonTitle:@"Not right now" otherButtonTitles:@"Sure",nil];
[alert show];


[[NSUserDefaults standardUserDefaults]setInteger:1 forKey:@"App_Testy_ICream_Counter"];

}

No comments:

Post a Comment