确定我的应用是否已更新的最佳方法

Chr*_*ken 4 iphone objective-c xamarin.ios ipad ios

我有一个IOS应用程序,每次更新我想做一些房屋清洁.确定IOS应用程序是否已更新的最佳方法是什么?

Joe*_*Joe 12

最简单的方法可能是获取当前版本,将版本与保存的版本(如果有)进行比较,必要时执行清理,保存新版本.以下是检索和存储版本信息以进行比较的示例.

//Getting the application version
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

//Retrieving the saved application version
NSString *savedVersion = [[NSUserDefaults standardUserDefaults] stringForKey:@"versionkey"];

//Saving the version
[[NSUserDefaults standardUserDefaults] setObject:version forKey:@"versionkey"];
Run Code Online (Sandbox Code Playgroud)

如果您想知道如何比较版本这里是使用NSNumericSearch比较选项的示例:http://spitzkoff.com/craig/?p = 148