应用程序更新,NSURL和文档目录 [英] App Updates, NSURL, and Documents Directory

查看:90
本文介绍了应用程序更新,NSURL和文档目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序商店中有一个应用程序,它使用Core Data来保存大部分数据。
例外是存储图像。我将子目录中的图像存储到Documents目录,并将NSURL引用存储在核心数据存储中相应的对象属性中。

I have an app in the app store that uses Core Data to persist much of the data. The exception is storing images. I store images in subdirectories to the Documents directory and store an NSURL reference to that image in the appropriate object attribute in the core data store.

我们注意到,当更新使其进入应用程序商店,使用与先前版本的应用程序一起存储的引用,找不到这些图像,因此不显示这些图像。
现在,我怀疑问题在于,因为我们使用开发设备进行测试,所以这个问题会传播,因为dev应用程序使用的Applications目录中的Directory与App Store正在创建的目录不同/使用。我注意到应用程序中App的App store目录与Xcode中调试版本时创建的App Store目录之间存在差异。
因此,存储在核心数据中的URL指向错误的应用程序文件夹。
这有点难以调试,因为一旦新版本在商店发布,我就无法下载旧的应用程序版本。

We have noticed that, when an update makes it to the app store, those images are not found, and thus don't display, using the references stored with the previous version of the app. Now, I have a suspicion that the problem is that, since we are using development devices for testing, this issue propagates because the Directory in the Applications directory to which the dev app uses differs from the one the App store is creating/using. I have noticed differences between the App store directory for the app in Applications and the one created while debugging versions in Xcode. As such, the URL stored in core data points to the wrong applications folder. This is kinda hard to debug, as I cannot download an older app version, once the new version has been released in the store.

所以我有一个几个问题。我可以保证下载同一个应用程序版本的人员所在的Applications子目录是相同的,这对非开发设备来说是非问题吗?

So I have a couple questions. Can I guarantee that the Applications subdirectory in which folks who download versions of the same app will be the same, rendering this a non-issue for non-development devices?

应该我存储相对图像网址或字符串来表示这些资源的位置,或者我应该将其存储到最终为绝对网址?

Should I be storing relative image url's or strings to represent the location of these resources, or should I be fine with storing what ends up being the absolute urls?

非常感谢,
Felipe

Thanks so much, Felipe

推荐答案

您应该使用相对URL来存储对文件的引用。应用更新后绝对URL可能会更改

You should use relative URLs to store references to files. The absolute URL is likely to change after an app update


应用更新期间保存的文件

当用户下载应用更新时,
iTunes会在新的应用目录中安装更新。然后,在删除旧安装之前,它会将
用户的数据文件从旧安装移动到新的app
目录。保证在更新过程中保留以下
目录中的文件:

When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation. Files in the following directories are guaranteed to be preserved during the update process:


  • Application_Home / Documents

  • Application_Home / Library

虽然其他用户目录中的文件
也可以移动,但你不应该在更新后,他们会依赖

Although files in other user directories may also be moved over, you should not rely on them being present after an update.

https://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ PerformanceTuning / PerformanceTuning.html

Thx到沙箱,应用程序主页也是用户主页。因此可以使用unix代字号,这是用户家的简写,即〜/ Documents 〜/ Library 等等。

Thx to the sandbox, the application home is also the user home. So it is possible to use the unix tilde which is a short hand to the user home, i.e. ~/Documents, ~/Library and so on.

使用 - [NSString stringByAbbreviatingWithTildeInPath] 将完整路径转换为相对路径。并用 - [NSString stringByExpandingTildeInPath] 反转它。

Use -[NSString stringByAbbreviatingWithTildeInPath] to turn a full path into a relative ~ path. And reverse it with -[NSString stringByExpandingTildeInPath].

这篇关于应用程序更新,NSURL和文档目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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