我有一个 iOS PhoneGap 应用程序,通过 https 连接到服务器。在 (App_name)/Library/(BundleId)/Cache.db (cfurl_cache_response) 下存储了客户端想要删除的用户的一些信息。我已经解决了存储问题,但我想在用户更新应用程序时删除 cache.db 中旧的存储信息。这在编程上可行吗?
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];
}
Run Code Online (Sandbox Code Playgroud)
这在 didFinishLaunchingWithOptions 中为我完成了工作。
| 归档时间: |
|
| 查看次数: |
3312 次 |
| 最近记录: |