You could save a value (e.g. the current app version number) to NSUserDefaults
and check it every time the user starts the app.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // ... NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *currentAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; NSString *previousVersion = [defaults objectForKey:@"appVersion"]; if (!previousVersion) { // first launch // ... [defaults setObject:currentAppVersion forKey:@"appVersion"]; [defaults synchronize]; } else if ([previousVersion isEqualToString:currentAppVersion]) { // same version } else { // other version // ... [defaults setObject:currentAppVersion forKey:@"appVersion"]; [defaults synchronize]; } return YES;}
The swift-2 version looks like this:
let defaults = NSUserDefaults.standardUserDefaults()let currentAppVersion = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! Stringlet previousVersion = defaults.stringForKey("appVersion")if previousVersion == nil { // first launch defaults.setObject(currentAppVersion, forKey: "appVersion") defaults.synchronize()} else if previousVersion == currentAppVersion { // same version} else { // other version defaults.setObject(currentAppVersion, forKey: "appVersion") defaults.synchronize()}
The swift-3 version looks like this:
let defaults = UserDefaults.standardlet currentAppVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! Stringlet previousVersion = defaults.string(forKey: "appVersion")if previousVersion == nil { // first launch defaults.set(currentAppVersion, forKey: "appVersion") defaults.synchronize()} else if previousVersion == currentAppVersion { // same version} else { // other version defaults.set(currentAppVersion, forKey: "appVersion") defaults.synchronize()}