发布新版本的应用程序会删除旧版本的文件吗?

发布于 2024-12-15 13:22:49 字数 131 浏览 0 评论 0原文

我将发布我的应用程序的新版本。以前的版本使用了一些文件,这些文件在新版本中已更改并需要处理。我希望当用户更新应用程序时自动删除旧文件,否则应用程序会看到它们并将处理它们(由于文件格式更改而导致错误)。 有没有办法做到这一点?

谢谢。

I'm gonna release a new version of my app. The previous version used some files which in the newer version are changed and need to be processed. I want the older files to be automatically deleted when the user updates the application, otherwise the application sees them and will process them (resulting in an error because the format of the files changed).
Is there an option to do that?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风和你 2024-12-22 13:22:49

由于您正在处理这些文件,一种选择是以某种方式将格式版本放入文件或文件夹路径中。将该版本烘焙为应用程序中的常量。

该应用程序可以始终通过将常量附加到获取这些文件的路径来查找这些文件,也可以查看文件的数据以获取格式版本并正确处理它(删除、重新下载等...)。

另一个好处是,如果您发布应用程序并且格式版本没有更改(可能 - 您只是修复了错误),则不必删除并重新下载这些文件。您也不必更改任何内容或更新任何例程 - 只需不更改文件格式常量,它就不会更改您的文件。如果您更改文件的格式,请更新该常量,它就会起作用。

Since you are processing these files, one option is to somehow put the format version in the files or in folder path. Bake that version into a constant in the app.

The app can either always look for those files by appending the constants to the path where you get these files, or look into the data of the file to get the format version and handle it properly (delete, redownload etc...).

Another benefit is that if you release your app and the format version does not change (likely - you just fixed bugs), you don't have to delete and re-download those files. You also don't have to change anything or update any routines - simply don't change the file format constant and it won't change your files. If you change the format of the files, update that constant and it just works.

空气里的味道 2024-12-22 13:22:49

从代码中的包中获取应用程序的版本并根据需要执行必要的更改始终是一个好习惯:

NSString* versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];

然后您可以比较此字符串(或字符串的浮点版本)以确定对数据进行哪些更改。您可以删除旧数据(如您的情况),或提取一些旧数据并创建新数据(通常的方式),或者应用程序可能根本不需要更改。

要记住的重要一点是,您可能会上传/发布应用程序的多个版本,而某些用户可能尚未下载较新的版本。因此,最好让方法根据版本字符串更新数据,而不是期望它是数据的最后一个版本。

It's always a good practice to get the version of your app from the bundle in code and perform necessary changes as needed:

NSString* versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];

Then you can compare this string (or float version of the string) to determine what changes to make to the data. You might delete the old data (as in your case), or extract some of the old data and create new data (the usual way), or the app may need no changes at all.

The BIG thing to keep in mind is you may upload/release several versions of an app and some users may not have downloaded the newer versions. Because of this, it's good practice to have methods update the data based on the version string, instead of expecting it to be the last version of the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文