Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data Relationship - Add to existing value
    primarykey
    data
    text
    <p>I am trying to set a relationship between inputted core data values. I currently have it set up so when I add the value it creates the relationship in the corresponding entity which I can view in a detail view. </p> <p>What I am trying to achieve is to add the relationship to a existing value within the entity that is held in a string <code>RoutineText</code>. So instead of creating a second identical entry the relationship is added to the new entry. So in the detail view both entries will be viewable.</p> <p><strong>The current situation when inputing the values</strong> <img src="https://i.stack.imgur.com/eTOjD.png" alt="The current situation when inputing the values"></p> <p>So instead of it creating:</p> <p><strong>TestName1</strong> ----> <strong>TestName1Detail</strong></p> <p><strong>TestName1</strong> ----> <strong>TestName2Detail</strong></p> <p>it would create:</p> <p><strong>TestName1</strong> ----> <strong>TestName1Detail</strong> + <strong>TestName2Detail</strong></p> <pre><code> NSManagedObjectContext *context = [self managedObjectContext]; // Create a new device ExcerciseInfo *info = [_fetchedResultsController objectAtIndexPath:indexPath]; Routines *routineEntity = [NSEntityDescription insertNewObjectForEntityForName:@"Routines"inManagedObjectContext:context]; RoutinesDetails *routineEntityDetail = [NSEntityDescription insertNewObjectForEntityForName:@"RoutinesDetails" inManagedObjectContext:context]; //Create Relationship [routineEntity addRoutinedetObject:routineEntityDetail]; //Add attribute values //[routineEntity setValue: RoutineText forKey:@"routinename"]; [routineEntityDetail setValue: info.name forKey:@"image"]; NSError *error = nil; // Save the object to persistent store if (![context save:&amp;error]) { NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]); } </code></pre> <p>I hope that is clear. <img src="https://i.stack.imgur.com/N0qOe.png" alt="enter image description here"></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.
    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