Application Updates, NSURL and Document Catalog

I have an application in the app store that uses Core Data to save most of the data. An exception is the storage of images. I store images in subdirectories in the Documents directory and save the NSURL link to that image in the corresponding object attribute in the master data store.

We noticed that when the update gets into the application store, these images were not found and, therefore, are not displayed using the links stored in the previous version of the application. Now I have a suspicion that the problem is that since we use development devices for testing, this problem is distributed, because the directory in the application directory to which the dev application is applied is different from the one that the application store creates / uses. I noticed differences between the App Store directory for the application in applications and the one that was created when debugging versions in Xcode. Thus, the URL stored in the master data points to the wrong application folder. This is pretty hard to debug as I cannot download an older version of the application as soon as the new version is released in the store.

So, I have a couple of questions. Can I guarantee that the Applications subdirectory in which users downloading versions of the same application will be the same, which makes this a problem without problems for non-working devices?

Should I store a relative URL or image strings to represent the location of these resources, or should I be fine while preserving what ultimately are absolute URLs?

Thanks a lot, Felipe

+7
source share
2 answers

You must use relative URLs to store file links. Absolute URL may change after application update

Files saved during application updates

When a user downloads an application update, iTunes installs the update in the new application directory. It then moves the user data files from the old installation to the new application before uninstalling the old installation. Files in the following directories are guaranteed to be saved during the upgrade process:

  • Application_Home / Documents
  • Application_Home / Library

Although files in other user directories can also be moved, you should not rely on them to be present after the upgrade.

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

thanks to the sandbox, the home application is also a home user. Thus, you can use the unix tilde, which is a short hand for the user, i.e. ~/Documents , ~/Library , etc.

Use -[NSString stringByAbbreviatingWithTildeInPath] to include the full path in the relative ~ path. And change it to -[NSString stringByExpandingTildeInPath] .

+13
source

I think you are looking for the following:

 NSString *appDocumentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 
0
source

All Articles