Reputation: 2992
I would like to know how to show an UIAlertView or a UIView ONLY at the first launch of my application.
Thanks.
Upvotes: 2
Views: 1078
Reputation: 11038
Use NSUserDefaults
to store a BOOL, like so:
-(void) showFirstRunAlerts {
BOOL ranBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"RanBefore"];
if (!ranBefore) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Message title."
message:@"Your message."
delegate:self
cancelButtonTitle:@"Thanks!"
otherButtonTitles:nil];
[alert show];
[alert release];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RanBefore"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
Upvotes: 8