title: CORE DATA Many to Many relationship. How to update or set relationship?
body: <p>I have 2 entities Locations and Items. Many to many relationship.</p>
  
  <p>So each item can have multiple locations and any location can have multiple items.</p>
  
  <p>I'm parsing an XML of items and than trying to add locations. </p>
  
  <p>So I have ManagedObject item and I have just inserted the location, so what's the syntax (code) to set the items location? </p>
  
  <p>I see only add and remove in ManagedObject Class.</p>
  
  <p>Is below is valid
  where currentItem,location are two ManagedObjects and setItem_location_relationship is the name of relationship in Items entity</p>
  
  <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
          NSEntityDescription *entity = [NSEntityDescription entityForName:@"Locations"
                                                    inManagedObjectContext:managedObjectContext];
          [fetchRequest setEntity:entity];
  
          NSPredicate *predicate = [NSPredicate predicateWithFormat:@"location_id = %@",
                                    [locationsArray objectAtIndex:i]];
          [fetchRequest setPredicate:predicate];
  
          NSError *error = nil;
          NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:fetchRequest error:&amp;error];
          if (fetchedObjects == nil) {
  
          }
  
          [fetchRequest release];
  
          Locations *location = [fetchedObjects objectAtIndex:0];
  
          NSSet *set = [NSSet setWithObject:location];
  
          [currentItem setItem_location_relationship:set];
  </code></pre>