开发者

Cocoa error 260

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.)

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.

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


I've tried cleaning targets, resetting device, resetting 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:

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.


Cocoa error 260

This solution resolves my problem i hope it will helps you out.


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:

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:

Change the '260' with the error code you want. The above command returns the following:

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':

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


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

}

-(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).


In my case my 260 error was due to a folder in the path Being camelCase.

In the simulator it worked fine under OSX. However on an iOS Device the case became very important.

I.E. I was referencing a folder called ``@"/Data/somethings/"``` On disk this was /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/


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..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜