开发者

Issue with NSSearchPathForDirectoriesInDomains And Persistent Data

As suggested, we're using the following code to retrieve the user document's path

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

we get the following path a开发者_如何学Pythons as result: /var/mobile/Applications/3E3C1F45-6649-4EA3-93FD-CDB802E346EC/Documents/

In said path, we save all the user's persistent data.

We encountered some problem with users who upgraded the application's version from the app-store, the persistent data is no longed read, perhaps the path is changed, maybe a new GUID is used within the new version.

Since this happens only after an appstore update, with a limitied ability to test and debug this issue.


When the user upgrades the App, the identifier (3E3C1F45-6649-4EA3-93FD-CDB802E346EC) can change but the documents and caches should be copied to the new directory from the old one.

Is there any chance that you are saving the ABSOLUTE path to your persistent data and trying to use it when loading files? You should be saving only the filenames and directory names within the documents directory, and generating the full path every time you load a resource (or at least at startup) by appending the path returned by NSSearchPathForDirectoriesInDomain

In other words, don't save PATHS such as

/var/mobile/Applications/3E3C1F45-6649-4EA3-93FD-CDB802E346EC/Documents/MyDirectory/MyFile.txt

Instead save:

/MyDirectory/MyFile.txt

and append it to whatever is returned by NSSearchPathForDirectoriesInDomain at runtime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜