title: Core Data Saving Attributes Of Entities
body: <p>This question is about Core Data.</p>
  
  <p>I created a Entity called <strong>TV</strong> with three attributes called <strong>name</strong>, <strong>price</strong> and <strong>size</strong>. I also created a subclass of NSMutableObject with <strong>TV.h</strong> and <strong>TV.m</strong> files.</p>
  
  <p>I imported the <strong>TV.h</strong> to my <strong>DetailViewController.h</strong> which handles my sliders und UIElements I want to take the values of.</p>
  
  <p>So I did a fetch request, and everything works fine, <strong>BUT</strong>:</p>
  
  <p>Everytime I update the UISlider (valueDidChange:), Xcode creates a <strong>COPY</strong> of my entity and adds it to my <strong>TV-Object</strong>.</p>
  
  <p>All I want Xcode is just to <strong>edit and save to the current entity</strong>, not to <strong>edit and save in a new entity</strong>.</p>
  
  <p>Help is very appreciated!</p>
  
  <p>Thank you in advance.</p>
  
  <p>My Code:</p>
  
  <p><code>DetailViewController.m</code></p>
  
  <pre><code>- (IBAction)collectSliderValue:(UISlider *)sender {
  
  if (__managedObjectContext == nil) {
      NSLog(@"Problem ...");
      __managedObjectContext = [(MasterViewController *)[[UIApplication sharedApplication] delegate] managedObjectContext];
      NSLog(@"... solved!");
  }
  
  if (sender == sizeSlider) {
  
      NSError *error = nil;
  
      NSManagedObjectContext *context = [self managedObjectContext];
  
      NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
      NSEntityDescription *entity = [NSEntityDescription entityForName:@"TV" inManagedObjectContext:context];
      [fetchRequest setEntity:entity];
      NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&amp;error];
  
      TV * currentTV = [[TV alloc] initWithEntity:entity insertIntoManagedObjectContext:context];
  
      currentTV.size = [[NSNumber alloc] initWithInt:(sender.value + 0.5f)];
      currentTV.name = @"New TV!";
  
      NSError *error11;
      [__managedObjectContext save:&amp;error11];
  
      for (NSManagedObject *info in fetchedObjects)
      {
          NSLog(@"Name = %@", [info valueForKey:@"name"]);
          NSLog(@"Size = %@", [info valueForKey:@"size"]);
          NSLog(@"Price = %@", [info valueForKey:@"price"]);
      }
      [fetchRequest release];
  }
  </code></pre>