iOS App更新新版本从Documents文件夹中删除文件 [英] iOS App update new version delete files from Documents folder

查看:108
本文介绍了iOS App更新新版本从Documents文件夹中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了iOS应用程序的新版本(1.0.1).该应用程序的背景是它从服务器下载文件并存储在Documents中.根据Apple指南,用户生成的任何文件都不应备份到云上,因此我将其标记为NSURLIsExcludedFromBackupKey.但是现在,当我使用Adhoc分发配置文件在设备上进行更新时,Documents文件夹中任何用户生成的文件都将被删除.

I have written a new version (1.0.1) of the iOS application. The background of the application is that it download files from server and stores in Documents. As per Apple guidelines, any file generated by user shouldn't be backed up on cloud, therefore I have marked them as NSURLIsExcludedFromBackupKey. But now when I am updating on the device using Adhoc distribution profile, any user generated file in Documents folders are getting deleted.

有什么办法可以避免删除这些文件,因为这些文件是运行应用程序所必需的文件.

Is there any way to avoid the deletion of those files, as these are essential files to have for application to run.

推荐答案

您似乎倒退了.您应该备份用户生成的文件.您不应该备份的文件可以很容易地替换,只需重新下载它们或根据需要再次生成即可.

You seem to have things backwards. You should backup user-generated files. What you should not backup are files that can easily be replaced by downloading them again or generating them again as needed.

如果您标记了文件以便将其从备份中排除,则意味着可以轻松地替换文件.

If you mark a file so it is excluded from backup then that means the file can easily be replaced.

在安装应用程序更新时,这些文件不会复制到更新的应用程序中.在首次运行时,您的应用程序应检测到它们丢失,并在需要时自动将其替换.

When you install the app update, those files aren't copied over to the updated app. On first run, your app should detect that they are missing and automatically replace them if needed.

如果这些文件无法自动替换,请不要使用 NSURLIsExcludedFromBackupKey 进行标记.

If these are files that can't be replaced automatically then do not flag them with NSURLIsExcludedFromBackupKey.

这篇关于iOS App更新新版本从Documents文件夹中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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