[英]What is the default folder to save files within an app in iOS 8
I have an app that saves files in iOS 7 without a problem and I can find them on iPad. 我有一个应用程序,可以毫无问题地保存iOS 7中的文件,我可以在iPad上找到它们。 The path is: /var/mobile/Applications/"UDID"/Documents The same app in iOS 8 and I cannot save the files and/or find them if they are saved somewhere.
路径是:/ var / mobile / Applications /“UDID”/ Documents iOS 8中的相同应用程序和我无法保存文件和/或找到它们,如果它们保存在某处。 It tries to save it to /private/var/Containers/Bundles/Application/"UDID"/Documents but then it tries to load the saved file from /private/var/Containers/Bundles/Application/"UDID" and I am unable to change directory to /private/var/Containers/Bundles/Application/"UDID"/Documents to find the file.
它试图将它保存到/ private / var / Containers / Bundles / Application /“UDID”/ Documents但是它尝试从/ private / var / Containers / Bundles / Application /“UDID”加载保存的文件,我无法将目录更改为/ private / var / Containers / Bundles / Application /“UDID”/ Documents以查找文件。 Any insight?
任何见解?
You should read TN2406: Changes to App Containers in iOS 8 , which tells us the following (emphasis added): 您应该阅读iOS 8中的TN2406:App Containers的更改 ,它告诉我们以下内容(重点已添加):
iOS 8 changes the locations of the standard directories used for storing user and app data (eg Documents, Library).
iOS 8更改用于存储用户和应用程序数据的标准目录的位置(例如,文档,库)。 While the locations of these directories have always been an implementation detail, some applications improperly assume that the Documents and Library directories reside in the same directory as the application's bundle.
虽然这些目录的位置始终是实现细节,但某些应用程序不正确地假设Documents和Library目录与应用程序的bundle位于同一目录中。 iOS 8 splits the data of an application from the application bundle.
iOS 8从应用程序包中分离应用程序的数据。 Code which attempts to derive the path to the Documents or Library directories will return an invalid path on iOS 8. Attempting to access this path will fail, and may terminate your app.
尝试派生Documents或Library目录路径的代码将在iOS 8上返回无效路径。尝试访问此路径将失败,并可能终止您的应用程序。
It also explains how to use NSFileManager to get the location of the Documents directory, essentially this: 它还解释了如何使用NSFileManager获取Documents目录的位置,基本上如下:
NSURL *documentsDirectoryURL = [[[NSFileManager defaultManager]
URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask]
lastObject];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.