【发布时间】:2013-04-12 20:56:23
【问题描述】:
我有一个 Ipad 应用程序,可以从 Internet 下载不同的文件。当我使用 Xcode Simulator 时,这个 App 效果很好。当我在 Ipad 上尝试应用程序时,应用程序开始时出现错误,并且由于此错误,应用程序无法运行。
error creating directory in createPath: Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x2d3eb0 {NSFilePath=/var/mobile/Applications/DE851748-0D7A-4416-9B62-8EEEF9B80533/Cache, NSUnderlyingError=0x2cb8e0 "The operation couldn’t be completed. Operation not permitted"}
我创建文件夹的代码:
-(void) createPath{
NSError *error;
[[NSFileManager defaultManager] createDirectoryAtPath:masterFolder
withIntermediateDirectories:YES
attributes:nil
error:&error];
if (error != nil) {
NSLog(@"error creating directory in createPath: %@", error);
}
}
这里是我的变量:
masterFolder = [NSHomeDirectory() stringByAppendingPathComponent:@"/Cache/"];
这是我知道的 Code 513 的一个老问题,我解释一下我到目前为止所做的事情:
- 我从模拟器(重置)和 Ipad 中手动删除了应用程序
- 将 StringByAppendingString 更改为 StringByAppendingPathComponent,如下所示:Save UIImage in application path
- 我使用了来自 Apple 的标准文件夹“缓存”,就像这里 NSFileManager creating folder (Cocoa error 513.)
- 是的,我已经重新启动了我的 Mac ;)
还有更多网站。但我不明白为什么模拟器的工作方式与原始 Ipad 不同。还是我监督了什么?!?谢谢!
【问题讨论】:
标签: xcode ipad ios-simulator nsfilemanager