Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Diary App Using Core Data Listing Data using NSFetchedResultsController Fetched Results Controller

Error when trying to display the table view controller

my console display this when i try to run application :

2014-12-03 17:33:32.824 Diary[73783:1232899] CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/youcef/Library/Developer/CoreSimulator/Devices/33360109-2254-4056-9F42-C166F2B6F179/data/Containers/Data/Application/5B6238D2-5020-4815-93E7-E4474701CE9C/Library/Documentation/Diary.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)" UserInfo=0x7fc303750ea0 {reason=Failed to create file; code = 2} with userInfo dictionary { reason = "Failed to create file; code = 2"; } 2014-12-03 17:33:32.825 Diary[73783:1232899] Unresolved error Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x7fc30353e040 {NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x7fc303750f60 "The operation couldn’t be completed. (Cocoa error 512.)"}, { NSLocalizedDescription = "Failed to initialize the application's saved data"; NSLocalizedFailureReason = "There was an error creating or loading the application's saved data."; NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=512 \"The operation couldn\U2019t be completed. (Cocoa error 512.)\" UserInfo=0x7fc303750ea0 {reason=Failed to create file; code = 2}"; }

4 Answers

Did you try deleting the app from the simulator and then re running the app?

Yes i tried and I also download the zip file of the video but same error.

Marius Kildedal
Marius Kildedal
8,096 Points

Check this in the CoreDataStack. you may have a typo and point to the Documentation directory and not the Document directory

NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
    NSLog(@"%@", url.absoluteString);```

I had this same problem. It turns out that Xcode autocompleted "NSDocumentationDirectory" instead of "NSDocumentDirectory" and I didn't catch it. When I switched it (as suggested above), it worked.