Created
April 17, 2013 17:06
-
-
Save benvium/5406028 to your computer and use it in GitHub Desktop.
iPhone / iOS: Detect if user has run this version before
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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