Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data Relationship Failing to Load To-One Relationship
    text
    copied!<p>I have a to-one relationship between a Document and Settings model:</p> <p><img src="https://i.stack.imgur.com/DRen1.png" alt="alt text"></p> <p>On creation of a Document, a corresponding Settings object is created. The models are persisted to core data.</p> <p>When relaunching after creating a few documents (and the associate settings), the application reloads a list of documents to select using:</p> <pre><code>// Load delegate from shared application and context from delegate. SampleAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *context = delegate.managedObjectContext; // Create new request. NSFetchRequest *request = [[NSFetchRequest alloc] init]; // Create entity description using delegate object context. NSEntityDescription *entity = [NSEntityDescription entityForName:@"Document" inManagedObjectContext:context]; // Set entity for request. [request setEntity:entity]; // Load array of documents. NSError *error; NSArray *documents = [context executeFetchRequest:request error:&amp;error]; // Rlease descriptor. [descriptor release]; // Release request. [request release]; // Done. return documents; </code></pre> <p>The list appears fine (the documents are loading). However, when attempting to access the settings for any of the documents the program exits giving:</p> <blockquote> <p>Program received signal: “SIGABRT”.</p> </blockquote> <p>The modifications to the settings are triggered when a user selects a button. Strangely enough, the program does not crash if the following snippet is added just before returning the documents on load (i.e. if the relationships are accessed while loading):</p> <pre><code>for (Document *document in documents) { NSLog(@"document.name: %@", document.name); NSLog(@"document.settings.stroke: %@", document.settings.stroke); NSLog(@"document.settings.stroke: %@", document.settings.stroke); } </code></pre> <p>The property for the relationship is "(nonatomic, retain)" and uses "@dynamic". Any ideas? Thanks!</p>
 

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