I want to update my application on the App Store. When the application opens first after the update, I want it to sync some things. So I need a way to check if it is the first one after the update.
The solution I was thinking of is this: save the version of the application NSUserDefaultsas follows:
NSString *oldVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"appVersion"];
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:@"appVersion"];
[[NSUserDefaults standardUserDefaults] synchronize];
I now have oldVersionand currentVersion, and all I have to do is compare them. I want to know if less oldVersion currentVersion. But these are strings. how can i check if oldVersion < currentVersion?
I know that I can just check if they are equal. But I want to be ready for future updates. Because maybe the synchronization I want to do for this 2 will be different for version 3, etc.
source
share