【发布时间】:2011-07-11 20:53:58
【问题描述】:
我试图读取模拟器中 Documents 目录中的所有文件,但我收到 Cocoa 错误 260。当我登录 [self applicationDocumentsDirectory] 时,它显示 /var/root/Documents。有谁知道为什么会发生这种情况?只有当我从命令行运行时才会发生这种情况。在模拟器本身中运行时,代码会正确输出模拟器的正确文档文件夹。
更新我现在看到“file://localhost/Users/MyUserName/Documents”的路径。好诡异……
- (NSString *)applicationDocumentsDirectory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
return basePath;
}
【问题讨论】:
-
从命令行运行是什么意思?
-
我们正在通过命令行运行我们的单元测试,但我已经发现了问题。谢谢!
标签: iphone objective-c ios xcode ios-simulator