Cocoa error 512 - anybody else?


#1

I’ve been trying to debug this issue for a while now, but the last section where you store information to a local database seems to be giving me a problem. It crashes out here:

    if (![psc addPersistentStoreWithType:NSSQLiteStoreType
                               configuration:nil
                                         URL:dbURL
                                     options:nil
                                       error:&error]){
            [NSException raise:@"Open failed"
                        format:@"Reason: %@", [error localizedDescription]];
    }

And the error is:

Nerdfeed[14975:907] *** Terminating app due to uncaught exception ‘Open failed’, reason: ‘Reason: The operation couldn’t be completed. (Cocoa error 512.)’
*** First throw call stack:

I think it has something to do with the path used for the database:

dbPath = [dbPath stringByAppendingPathComponent:@“feed.db”];

I have tried deleting the app, running it again, running it on a simulator etc… nothing seems to work.

anybody have any tips or things i can look into?


#2

Do an NSLog on the dbPath to make sure that path is present. Make sure the path is pointing to NSDocumentDirectory and NOT NSDocumentationDirectory (read it closely). If it’s ‘Documentation’ then you can’t write to that directory and will get 512 error.

    NSString *dbPath =
        [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                             NSUserDomainMask,
                                             YES) objectAtIndex:0];
    dbPath = [dbPath stringByAppendingPathComponent:@"feed.db"];

#3

Thanks, it was the typo error of NSDocumentDirectory.

Much appreciated!


#4

That fixed my issue as well. Thank you sir!


#5

Same here. NSDocumentationDirectory
:facepalm:

Thanks for tracking this down for us :slight_smile:


#6

Same for me! Thanks so much!!


#7

Thanks so much!