iOS应用程序更新测试 [英] iOS Application Update Test

查看:111
本文介绍了iOS应用程序更新测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法虽然它想在应用程序更新时进行测试?

Is there a method though it wants to test when the application is updated?

我很尴尬,因为只有在应用程序更新时才会出现错误,它没有调查。

I am embarrassed because there is a bug that occurs only when the application is updated, and it doesn't investigate.

推荐答案

如果您想询问是否要通过应用程序商店更新应用程序,我不知道这样的方法。

If you are asking if you want to find when the application is updated through app store, I am not aware of such a method.

执行此操作的hackie方法是将当前应用版本保存到NSUserDefaults,然后检查NSUserDefaults应用版本是否等于当前应用版本。

A hackie approach to do this is to save the current app version to NSUserDefaults, then check if the NSUserDefaults app version is equal to the current app version.

例如:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSString *currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

    if ([defaults objectForKey:@"savedAppVersionKey"] != nil) {
        //key exists

        NSString *savedAppVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedAppVersionKey"];

        if ([currentAppVersion isEqualToString:savedAppVersion]) {
            //still running the same app version
        }
        else {
            //the app version changed from the last launch
        }

    }
    else {
        //first run, set the key & synchronize
        [[NSUserDefaults standardUserDefaults] setObject:currentAppVersion forKey:@"savedAppVersionKey"];

        [[NSUserDefaults standardUserDefaults] synchronize] 
    }

}

我没有测试过代码,但它应该有效。

I haven't tested the code, but it should work.

谢谢,

-David

这篇关于iOS应用程序更新测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆