Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to check if a relationship has been established - Core Data
    primarykey
    data
    text
    <p>How would you check if a relationship has been established when adding data to core data? Currently I have a <strong>TO MANY</strong> relationship between two of my entities.</p> <p>I am attempting to create a detail view but am struggling and i'm not sure if its due to a relationship not being established or if my issue is with passing the data over to the new view controller.</p> <p><img src="https://i.stack.imgur.com/iXBcS.png" alt="enter image description here"></p> <p>I am adding the the data to the core data entities using the following code. Does this look right when establishing a relationship between the two?</p> <pre><code> ExcerciseInfo *info = [_fetchedResultsController objectAtIndexPath:indexPath]; NSManagedObject *routineEntity = [NSEntityDescription insertNewObjectForEntityForName:@"Routines"inManagedObjectContext:context]; NSManagedObject *routineEntityDetail = [NSEntityDescription insertNewObjectForEntityForName:@"RoutinesDetails" inManagedObjectContext:context]; [[routineEntityDetail valueForKey:@"name"] addObject:routineEntity]; [routineEntity setValue: info.name forKey:@"routinename"]; [routineEntityDetail setValue: info.details.muscle forKey:@"image"]; NSError *error = nil; </code></pre> <p><strong>ERROR INVESTIGATION</strong></p> <p>I used one of the suggested methods but am still getting this fault when i tested the relationship in a <code>NSLog(@"ExTitle *** %@",Ex.routinedet);</code> with routinedet being the <code>@property (nonatomic, retain) NSSet *routinedet;</code> in the core data generated NSObject relationship model:</p> <pre><code>Relationship 'routinedet' fault on managed object (0x749ea50) &lt;Routines: 0x749ea50&gt; (entity: Routines; id: 0x749c630 &lt;x-coredata://C075DDEC-169D-46EC-A4B7-972A04FCED70/Routines/p1&gt; ; data: { routinedet = "&lt;relationship fault: 0x8184a20 'routinedet'&gt;"; routinename = "Leg Crunch"; </code></pre> <p>I have also tested to make sure the segue is working and its is as;</p> <pre><code>self.title = Ex.routinename; RoutinesDetails *info; NSLog(@"Image *** %@",info.image); </code></pre> <p>which shows the title as the correct name but returns image string as null.</p>
    singulars
    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.
 

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