cocoa错误260

我不断收到这个错误。 我通过FTP上传到服务器。 它工作正常,并在模拟器中运行时完全上传,但是当我在iPhone上configuration时,它会显示: Error Occurred. Upload failed: The operation couldn't be completed. (Cocoa error 260.) Error Occurred. Upload failed: The operation couldn't be completed. (Cocoa error 260.)

有什么build议么? 我一直在debugging和研究几个小时,无法弄清楚这一点。 我已经尝试清洗目标,重置设备,重置xcode。

我缩小的一件事是:

 NSError *attributesError = nil; NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.filePath error:&attributesError]; if (attributesError) { [self failWithError:attributesError]; return; } 

在设备attributesError是真实的,在模拟器中它是错误的

我已经尝试清洗目标,重置设备,重置xcode。

对随机目标的盲目冲击从来不是一个好的debugging技术。 充其量,你会解决这个问题,不知道如何。 最糟糕的是,你会打破别的东西。

相反,找出问题所在 。 对于一个“cocoa错误”,你会希望看到FoundationErrors.h和CoreDataErrors.h(和AppKitErrors.h不针对cocoa触摸)。 前面的文件给出了cocoa错误260的名称:

 NSFileReadNoSuchFileError = 260, // Read error (no such file) 

您无法获取该文件的属性,因为它不存在(在您的设备上)。

您可能需要编辑您的问题,以包含创build存储到self.filePath的path的代码。

在这里输入图像说明

这个解决scheme解决了我的问题,我希望它能帮助你。

我知道Peter Hosey已经解决了这个问题,但我想补充一些东西。 如果你想快速find你的错误,你可以在terminal中使用一个简单的命令来定位它的定义:

 ief2s-iMac:Frameworks ief2$ cd /System/Library/Frameworks ief2s-iMac:Frameworks ief2$ grep '260' $(find . -name "*Errors.h" ) 
  • cd到你的框架目录
  • grep所有以“Errors.h”结尾的错误代码的文件:

用你想要的错误代码改变'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$ 

你当然可以通过在'Error = 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$ 

我希望这可以帮助你进一步发展,ief2

 +(DataManager*)getSharedInstance{ if (!sharedInstance) { sharedInstance = [[super allocWithZone:NULL]init]; [sharedInstance copyDatabaseIntoDocumentsDirectory]; } return sharedInstance; 

}

– (无效)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]); } } 

}

注意:错误260:意味着在指定的path中找不到文件(再次创build数据库,然后添加项目)。

这个错误可以迅速的去除。 请不要将数据库文件拖放到项目中。 转到“添加文件”选项,然后导入文件。 我试了这个,错误消失了..

在我的情况下,我的260错误是由于path中的一个文件夹正在camelCase。

在模拟器,它在OSX下工作正常。 但是在iOS设备上,情况变得非常重要。

IE我引用了一个名为“@”/ Data / somethings /““`在磁盘上这是/ data / somethings /

iOS必须保持大写/小写的一致性。 所以我必须确保它总是被称为/ data / somethings /