1

我有一个通过 https 连接到服务器的 iOS phonegap 应用程序。在 (App_name)/Library/(BundleId)/Cache.db (cfurl_cache_response) 下为客户端想要删除的用户存储了一些信息。我已经修复了存储问题,但我想在用户更新应用程序时删除 cache.db 中的旧存储信息。这在编程上可行吗?

4

1 回答 1

4
BOOL isNotFirstTimeRun = [[NSUserDefaults standardUserDefaults] boolForKey:@"isnotfirsttimerun"];
if (!isNotFirstTimeRun) {
    // Clear the cache if this is a first time run
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    // Set the flag to true and synchronize the user defaults
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setBool:YES forKey: @"isnotfirsttimerun"];
    [defaults synchronize];
}

这在 didFinishLaunchingWithOptions 中为我完成了工作。

于 2013-06-10T08:22:39.570 回答