ios - 无需越狱访问应用程序文件夹

标签 ios objective-c nsarray sandbox nsfilemanager

我正在尝试访问应用程序文件夹,该文件夹允许在不越狱的情况下进行读取访问,但我得到一个空数组

NSArray *appFolderContents=[[NSFileManager defaultManager] 
                            directoryContentsAtPath:@"/var/mobile/Applications"];

最佳答案

您可以像这样访问您的应用程序目录

   NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
   NSFileManager *fileManager = [NSFileManager defaultManager];  
   NSLog(@"App Directory is: %@", appFolderPath);
   NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]);

请注意,您只能在根文件夹中读取,并在应用的 Documents 文件夹中写入和读取。

您无权访问应用程序包之外的任何文件夹。

关于ios - 无需越狱访问应用程序文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23870062/

相关文章:

iOS - ViewController 中的第三个 TableView 未加载 Nib

ios - 在 ios 上注册为组织

ios - Objective C - 按值传递和按引用传递

iphone - NSArray 的前三项变成 NSString?

ios - 显示加载数据时值被垃圾收集的空引用异常

iphone - 如何将 3 个参数传递给@selector

ios - NSAttributedString 不绘制带有 NSStrokeColorAttributeName 和 NSStrokeWidthAttributeName 设置的笔画

ios - UITableViewCell 中垂直居中右侧细节 UILabel

iOS - 关于内存管理的问题 : NSArray case

objective-c - 将 NSDictionary 中的每个 NSArray 更改为 Mutable