2

According to Apple's iOS Application Programming guide, application preserves documents and library directories. My question is what exactly library directory preserves? Does it copy user created files/data (if stored in library directory) as well or just preserves Preferences and application settings?

My app is currently storing user data in library directory and users lost their data on updating to newer version. I want not to happen this again.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hassan
  • 21
  • 2

2 Answers2

1

User created files and data should be stored in the documents folder. The contents in that folder is also backed up using iTunes.

werner
  • 859
  • 4
  • 8
0

Not only should you be saving user data in the documents directory.

/**
 Returns the path to the application's Documents directory.
 */
- (NSString *)applicationDocumentsDirectory {
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}

But you should also only store relative paths to the files located in that directory. If you store the absolute path, your app won't find the data after an update.

First App Update, User Data Lost (was stored in Documents directory)

Community
  • 1
  • 1
Andrew
  • 2,690
  • 23
  • 27