ios 可可错误 260
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4869856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cocoa error 260
提问by Chris
I keep getting this error. I'm uploading via ftp to a server. It works fine and uploads completely while running in the simulator, but when I provision it on my iPhone, it says:
Error Occurred. Upload failed: The operation couldn't be completed. (Cocoa error 260.)
我不断收到此错误。我正在通过 ftp 上传到服务器。它在模拟器中运行时运行良好并完全上传,但是当我在 iPhone 上配置它时,它说:
Error Occurred. Upload failed: The operation couldn't be completed. (Cocoa error 260.)
Any suggestions? I've been debugging and researching for hours on end and can't figure this out. I've tried cleaning targets, resetting device, resetting xcode.
有什么建议?我一直在调试和研究几个小时,但无法弄清楚这一点。我试过清理目标、重置设备、重置 xcode。
One thing I narrowed down was:
我缩小范围的一件事是:
NSError *attributesError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.filePath error:&attributesError];
if (attributesError) {
[self failWithError:attributesError];
return;
}
In the device attributesError is true, in the simulator it is false
在设备 attributesError 中为 true,在模拟器中为 false
回答by Peter Hosey
I've tried cleaning targets, resetting device, resetting xcode.
我试过清理目标、重置设备、重置 xcode。
Blind pounding on random targets is never a good debugging technique. At best, you'll fix the problem and not know how. At worst, you'll break something else.
盲目冲击随机目标从来都不是一个好的调试技术。充其量,您会解决问题,但不知道如何解决。最坏的情况是,你会破坏其他东西。
Instead, find out what the problem is. For a “Cocoa error”, you'll want to look in FoundationErrors.h and CoreDataErrors.h (and AppKitErrors.h when not targeting Cocoa Touch). The former file gives the name for Cocoa error 260:
相反,找出问题所在。对于“Cocoa 错误”,您需要查看 FoundationErrors.h 和 CoreDataErrors.h(当不针对 Cocoa Touch 时,还需要查看 AppKitErrors.h)。前一个文件给出了 Cocoa 错误 260 的名称:
NSFileReadNoSuchFileError = 260, // Read error (no such file)
You're unable to get the attributes of that file because it doesn't exist (on your device).
您无法获取该文件的属性,因为它不存在(在您的设备上)。
You may want to edit your question to include the code that creates the path that you store into self.filePath
.
您可能想要编辑您的问题以包含创建您存储到self.filePath
.
回答by Burhan Ahmad
This solution resolves my problem i hope it will helps you out.
此解决方案解决了我的问题,希望对您有所帮助。
回答by v1Axvw
I know Peter Hosey already has solved this question, but I want to add something. If you want to find your error quickly, you can use a simple command in the terminal to locate it's definition:
我知道 Peter Hosey 已经解决了这个问题,但我想补充一点。如果你想快速找到你的错误,你可以在终端中使用一个简单的命令来定位它的定义:
ief2s-iMac:Frameworks ief2$ cd /System/Library/Frameworks
ief2s-iMac:Frameworks ief2$ grep '260' $(find . -name "*Errors.h" )
- cd to your frameworks directory
- grep all the files ending with 'Errors.h' for the error code:
- cd 到您的框架目录
- grep 以“Errors.h”结尾的所有文件的错误代码:
Change the '260' with the error code you want. The above command returns the following:
使用您想要的错误代码更改“260”。上面的命令返回以下内容:
ief2s-iMac:Frameworks ief2$ grep '260' $(find . -name "*Errors.h" )
./CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h: midiDupIDErr = -260, /*duplicate client ID*/
./CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h: kECONNREFUSEDErr = -3260, /* Connection refused */
./Foundation.framework/Versions/C/Headers/FoundationErrors.h: NSFileReadNoSuchFileError = 260, // Read error (no such file)
ief2s-iMac:Frameworks ief2$
You could of course better specify it by doing a grep on 'Error = 260':
您当然可以通过对“错误 = 260”执行 grep 来更好地指定它:
ief2s-iMac:Frameworks ief2$ grep 'Error = 260' `find . -name "*Errors.h"`
./Foundation.framework/Versions/C/Headers/FoundationErrors.h: NSFileReadNoSuchFileError = 260, // Read error (no such file)
ief2s-iMac:Frameworks ief2$
I hope this can help you with your further development, ief2
我希望这可以帮助你进一步发展,ief2
回答by Venkatesh G
+(DataManager*)getSharedInstance{
if (!sharedInstance) {
sharedInstance = [[super allocWithZone:NULL]init];
[sharedInstance copyDatabaseIntoDocumentsDirectory];
}
return sharedInstance;
}
}
-(void)copyDatabaseIntoDocumentsDirectory{
-(void)copyDatabaseIntoDocumentsDirectory{
// Set the documents directory path to the documentsDirectory property.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
self.documentsDirectory = [paths objectAtIndex:0];
// Keep the database filename.
self.databaseFilename = DATABASE_FILENAME;
// Check if the database file exists in the documents directory.
destinationPath = [self.documentsDirectory stringByAppendingPathComponent:self.databaseFilename];
if (![[NSFileManager defaultManager] fileExistsAtPath:destinationPath]) {
// The database file does not exist in the documents directory, so copy it from the main bundle now.
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseFilename];
NSError *error;
[[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:destinationPath error:&error];
// Check if any error occurred during copying and display it.
if (error != nil) {
NSLog(@"%@", [error localizedDescription]);
}
}
}
}
Note : error 260 : meaning the file could not be found at the path you specified (once again create DB and then add your project).
注意:错误 260:表示在您指定的路径中找不到该文件(再次创建 DB,然后添加您的项目)。
回答by Danoli3
In my case my 260 error was due to a folder in the path Being camelCase.
在我的情况下,我的 260 错误是由于路径中的一个文件夹而造成的。
In the simulator it worked fine under OSX. However on an iOS Device the case became very important.
在模拟器中,它在 OSX 下运行良好。然而,在 iOS 设备上,案例变得非常重要。
I.E. I was referencing a folder called ``@"/Data/somethings/"``` On disk this was /data/somethings/
IE 我引用了一个名为 ``@"/Data/somethings/"``` 在磁盘上的文件夹,这是 /data/somethings/
You have to maintain a consistency of uppercase / lowercase for iOS. So I had to make sure it was always referred to as /data/somethings/
您必须为 iOS 保持大写/小写的一致性。所以我必须确保它总是被称为 /data/somethings/
回答by Aditya Sharma
This error can be removed vey quickly. Please do not drag and drop the database file into the project. Go to "Add files" option and then import the file. I tried this and error was gone..
这个错误可以很快消除。请不要将数据库文件拖放到项目中。转到“添加文件”选项,然后导入文件。我试过了,错误消失了..