iphone - 如何在 iOS 上获取 Unzip 文件夹的唯一路径

标签 iphone objective-c ios xcode ipad

在 iOS 上:
如何解决解压缩文件、获取唯一路径名、在其他 View 中使用此路径以及在 View 卸载后删除捕获文件的整个问题?

最佳答案

我会建议你使用时间戳,将其存储在 NSUserDefaults 中。

在 AppDelegate 的 applicationWillTerminate 方法上,检查 NSUserDefaults 是否具有您设置的 key ,如果有,则删除文件并删除 key 。

- (void)applicationWillTerminate:(UIApplication *)application
{
    if([[NSUserDefaults standardUserDefaults] objectForKey:@"KEY_FOR_PATH"] != nil)
    {
        [[NSFileManager defaultManager] removeItemAtPath:[[NSUserDefaults standardUserDefaults] objectForKey:@"KEY_FOR_PATH"] error:nil];
        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"KEY_FOR_PATH"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

关于iphone - 如何在 iOS 上获取 Unzip 文件夹的唯一路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13337750/

相关文章:

objective-c - 将 NSArray 传递给 cpp 函数

ios - 在 Swift 中禁用按钮

ios - 点击自定义注释并执行相应的功能

ios - 怎么设置game over在游戏结束的时候和开始的条件一样?

objective-c - 从 DetailView 快速导航中的 UISplitViewController

ios - 如何在 Swift 3.2 及以上版本中集成 instamojo

iphone - 从 fetchedResultsController 中删除对象 fetchedObjects

ios - NSLayoutContraints : How to position a bottom view below the higher of two labels?

iphone - 排序 UITableView 不工作

iPhone 配置实用程序 - 为 webapp 添加 webclip