我不确定这是否是您要查找的内容,但此代码可以通过将版本信息存储在 NSUserDefaults 中来告诉您您的应用程序是否已更新。
- (BOOL)wasUpdated {
// access NSUserDefaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// get previous version number from defaults
NSString *previousVersion = [defaults stringForKey:@"previousVersion"];
// get current version number from info plist
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
// check against previousVersion being nil
if (!previousVersion) {
// set current version to previous version
[defaults setObject:currentVersion forKey:@"previousVersion"];
// previousVersion didn't exist and can't be checked, return NO
return NO;
}
// return YES if the versions are not the same
if (NSOrderedSame != [previousVersion compare:currentVersion]) return YES;
// return NO if they are the same
return NO;
}
希望这就是你所需要的。如果我不明白你的意思,请告诉我。