Issue with NSSearchPathForDirectoriesInDomains And Persistent Data

时光怂恿深爱的人放手 提交于 2019-12-04 16:53:53

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!