简体   繁体   English

在iOS 8中,在应用程序中保存文件的默认文件夹是什么

[英]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.

相关问题 如何在App文件夹的文件夹内保存文件? Xamarin iOS - How to Save Files inside a folder in the App Folder ? Xamarin iOS 如何将文件从 iOS 反应本机应用程序保存到 Files 文件夹 - how to save file from an iOS react native app to Files folder Google Clould Messaging(iOS)将文件放入默认的应用程序文档文件夹中 - Google Clould Messaging (iOS) put files in default app Documents folder 将文件保存在app文件夹中 - Save files inside app folder iOS-允许其他应用编辑和创建我的应用创建的文件,并将其保存在从中打开文件的同一文件夹中 - iOS - letting another app edit and save files my app created, in the same folder where the file was opened from 在 Files 应用程序中显示 iOS 应用程序文件 - Showing iOS app files within in the Files app 为iOS应用程序的文件启用iCloud Drive文件夹 - Enabling iCloud Drive folder for files of an iOS app 在iOS应用程序的/ Documents /文件夹中提供初始文件 - Providing initial files in /Documents/ folder in an iOS app iOS 文档文件夹中包含文件的应用程序大小 - Size of app with files in documents folder iOS 我退出iOS企业应用程序后,文档文件夹中的文件会如何处理? - What happens to files in my documents folder when I resign my iOS enterprise app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM