Skip to content

Instantly share code, notes, and snippets.

@benvium
Created April 17, 2013 17:06
Show Gist options
  • Select an option

  • Save benvium/5406028 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/5406028 to your computer and use it in GitHub Desktop.
iPhone / iOS: Detect if user has run this version before
// Warn if this is the first run of this new version
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleVersion"];
NSString* defaultsKey = [NSString stringWithFormat:@"hasRunVersion%@", version];
BOOL hasRunThisVersion = [[NSUserDefaults standardUserDefaults] boolForKey:defaultsKey];
Log(@"hasRunThisVersion is %d", hasRunThisVersion);
if (!hasRunThisVersion) {
// Do things you want to happen only once
// Well, they've run it now
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:defaultsKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment