Note that there are some explanatory texts on larger screens.

plurals
  1. PONSPersistentStoreCoordinator not created on a UIManagedDocument
    primarykey
    data
    text
    <p>I'm starting to learn about <code>UIManagedDocument</code> and its abilities. From what I understand of it its a form of database stored in a location in the documents directory.</p> <p>Anyway, I'm trying to use it as a database, by storing data within its <code>NSManagedObjectContext</code> however, after a few seconds of creating the <code>UIManagedDocument</code> and saving data to its context (after I'm guessing timing out), the app crashes and it tells me there is no persistent store coordinator.</p> <p>There doesn't seem to be much guidance on the Apple docs as to how to create a persistent store coordinator after creating the managed document.</p> <p>How do I do this exactly?</p> <p>Thanks!</p> <p><em><strong>Edit</em></strong></p> <p>Code I'm using:</p> <pre><code>NSURL *url = [[self iCloudDocumentsURL] URLByAppendingPathComponent:nameOfDocument]; NSMutableArray *books = [self.books mutableCopy]; [books addObject:url]; [self setBooks:books]; UIManagedDocument *document = [[UIManagedDocument alloc] initWithFileURL:url]; NSDictionary *options = @{ NSMigratePersistentStoresAutomaticallyOption : @YES, NSInferMappingModelAutomaticallyOption : @YES, NSPersistentStoreUbiquitousContentNameKey : document.fileURL.lastPathComponent, NSPersistentStoreUbiquitousContentURLKey : [self iCloudCoreDataLogFilesURL] }; [document setPersistentStoreOptions:options]; if (document.documentState == UIDocumentStateClosed) { [document openWithCompletionHandler:^(BOOL success) { Book *book = [Book newBookWithTitle:bookTitle inManagedObjectContext:document.managedObjectContext]; [document updateChangeCount:UIDocumentChangeDone]; }]; } </code></pre> <p><em><strong>Update</em></strong></p> <p>After performing this code on a background thread. My app still logs 'NO' for the success on the completion handler after opening the document. However, my app does not crash, instead I get the following log:</p> <pre><code>2013-04-23 00:01:08.381 Notable[193:4b0b] -[_PFUbiquityRecordsImporter rollResponseOperation:encounteredAnError:whileTryingToAdoptBaseline:](1545): CoreData: Ubiquity: &lt;PFUbiquityBaselineRollResponseOperation: 0x1fa561d0&gt; localPeerID: mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A, storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B, modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas= ubiquityRootLocation: &lt;PFUbiquityLocation: 0x1e59b790&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs Encountered an error while trying to respond to the roll of baseline: &lt;PFUbiquityBaseline: 0x1e54deb0&gt;(0) permanentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip safeLocation: &lt;PFUbiquityLocation: 0x1f8eb1b0&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A currentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas= baselineArchiveLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip Error: Error Domain=NSCocoaErrorDomain Code=134310 "The operation couldn’t be completed. (Cocoa error 134310.)" UserInfo=0x1f8d2ae0 {baseline=&lt;PFUbiquityBaseline: 0x1e54deb0&gt;(0) permanentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip safeLocation: &lt;PFUbiquityLocation: 0x1f8eb1b0&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A currentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip storeName: A-B893A0AB-B764-42F1-9402-38790DCEF96B modelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas= baselineArchiveLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip , localStoreKV=&lt;PFUbiquityKnowledgeVector: 0x1f8220c0&gt; ()} userInfo: { baseline = "&lt;PFUbiquityBaseline: 0x1e54deb0&gt;(0)\n\tpermanentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n\tsafeLocation: &lt;PFUbiquityLocation: 0x1f8eb1b0&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/mobile.2DDB96C5-A317-5BE5-8F29-9F5E6681A27A\n\tcurrentLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n\n\tstoreName: A-B893A0AB-B764-42F1-9402-38790DCEF96B\n\tmodelVersionHash: NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=\n\tbaselineArchiveLocation: &lt;PFUbiquityLocation: 0x1f8e7120&gt;: /private/var/mobile/Library/Mobile Documents/my~app~identifier/Logs/.baseline/A-B893A0AB-B764-42F1-9402-38790DCEF96B/NK3BysbustJxxyi2O8bX8eof15YimkUnegxqX6HDkas=/baseline.zip\n"; localStoreKV = "&lt;PFUbiquityKnowledgeVector: 0x1f8220c0&gt; ()"; } </code></pre> <p>This method also creates a 'DocumentMetaData.plist' (which I believe is necessary according to this files mention in the CS193P video I mentioned in a comment) instead of a file entitled 'persistentStore'.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload