I use -[NSPersistentStore metadataForPersistentStoreOfType:URL:error:] for a variation of the reason stated in its documentation, which is "to retrieve the metadata from a store without the overhead of creating a Core Data stack.”
Sometimes, although I can’t reproduce it, this method fails. It seems to raise an exception which writes some stuff to the console, but does not re-throw, so I never @catch anything :( My code: if ([[NSFileManager defaultManager] fileExistsAtPath:[url path]]) { @try { metadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType URL:url error:&underlyingError] ; } @catch (NSException* exception) { // This never happens :( NSLog(@"Warning 514-0011 for %@ : %@", url, exception) ; } } Furthermore, when that method fails, if I put on my black hat and query the sqlite file using the sqlite.c library, I get all of the expected metadata with no problem. I’m thinking of using that in production. Does anyone know anything else which I should know? Thanks, Jerry More Details… I want the metadata prior to opening a document, specifically because I customize what happens when NSDocument fails to open a document due to, for example, it having been created with a newer version. This app is built with the 10.9 SDK but I have opted out of WAL journaling for sqlite, using legacy “rollback” or “delete” journaling. Here is the call stack which appears when I break in objc_exception_throw: #0 in objc_exception_throw () #1 in -[NSSQLiteConnection prepareSQLStatement:] () #2 in -[NSSQLConnection fetchMetadata] () #3 in -[NSSQLCore _loadAndSetMetadata] () #4 in -[NSSQLCore loadMetadata:] () #5 in +[NSSQLCore metadataForPersistentStoreWithURL:error:] () #6 in +[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] () #7 in +[MyClass codeYouSeeAbove] Here is an example of what gets logged to the console: 2014-02-11 14:33:55.030 MyApp[39446:303] CoreData: error: (14) I/O error for database at /path/to/Document.sql. SQLite error code:14, 'unable to open database file' _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com