Skip to content

Instantly share code, notes, and snippets.

@robwormald
Created January 10, 2014 22:25
Show Gist options
  • Save robwormald/8363896 to your computer and use it in GitHub Desktop.
Save robwormald/8363896 to your computer and use it in GitHub Desktop.
#define LAST_VERSION_RUN @"Settings.LastVersionRun"
-(BOOL)isFirstRunForVersion
{
// get the current version
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
// get the last version run
NSUserDefaults* preferences = [NSUserDefaults standardUserDefaults];
NSString *lastVersion = [preferences objectForKey:LAST_VERSION_RUN];
// is this a new version being run?
if (![currentVersion isEqual:lastVersion]) {
//do some stuff here
// yes, record this as the last version run now
[preferences setObject:currentVersion forKey:LAST_VERSION_RUN];
[preferences synchronize];
// return yes
return YES;
} else {
// no, return no
return NO;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment