title: Delete Object from Core data relationship - NSSet
body: <p>I have a one to many relationship between a Product entity and a Cart Entity.</p>
  
  <p>The user needs to have the opportunity to delete a product from the cart.  </p>
  
  <p>I fetch the products like so: </p>
  
  <pre><code>         // Fetch request for "Product":
  NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Product"];
  
  // Fetch only products for the cart:
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"inCart = %@", self.cart];
  [fetchRequest setPredicate:predicate]; 
  
  
  NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"navn" ascending:YES];
  [fetchRequest setSortDescriptors:@[sortDescriptor]];
  
  self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:_theManagedObjectContext sectionNameKeyPath:nil cacheName:nil];
  _fetchedResultsController.delegate = self;
  </code></pre>
  
  <p>and populate the tableview: </p>
  
  <pre><code>Product *prod = (Product *)[self.fetchedResultsController objectAtIndexPath:indexPath];
  </code></pre>
  
  <p>In the tableview I have a button and when you tap it, that current product, should get deleted... I have the following code in my "delete product method"</p>
  
  <pre><code>-(void)RemoveFromCart:(UIButton *)sender {
  
      UITableViewCell *cell = (UITableViewCell *)sender.superview;
      NSIndexPath *indexPath = [_Table indexPathForCell:cell];
  
      Product *prod = (Product *)[self.fetchedResultsController objectAtIndexPath:indexPath];
  
  
      /*_cart is retrieved when the user pushes the add to cart button, in another    viewcontroller, a cart object is then returned and passed to the cart viewcontroller */
      NSMutableSet *mutableSet = [NSMutableSet setWithSet:_cart.products];
  
          [mutableSet removeObject:prod];
          _cart.products = mutableSet;
  
  
  
      [self saveCurrentContext:_theManagedObjectContext];
  
  
      [_Table reloadData];
  
  
  
  
  }
  </code></pre>
  
  <p>But nothing happens, when the method is fired.. the product is not removed from the relationship. 
  How do I manage to fix this, my code is obviously wrong somewhere. </p>