• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
-[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] foibles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] foibles


  • Subject: -[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] foibles
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 11 Feb 2014 15:53:55 -0800

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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: -[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] foibles
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: NSOutlineView view-based SourceView HeaderCell text is not white when selected
  • Next by Date: Re: How do I animate Core Graphics drawing?
  • Previous by thread: Re: Requiring a User to Save a Document before Being Able to Edit It
  • Next by thread: Re: -[NSPersistentStoreCoordinator metadataForPersistentStoreOfType:URL:error:] foibles
  • Index(es):
    • Date
    • Thread