title: How to change record value in core data
body: <ol>
  <li>I have UITableView</li>
  <li>There is a UISwitch in all cells.</li>
  <li>My Core Data is filled by values.</li>
  <li>One of core data attribute named switchValue with @"OFF" value.</li>
  </ol>
  
  <p>now I need to:</p>
  
  <ol>
  <li>If the user set the UISwitch to ON.</li>
  <li>The action change the value of the switchValue attribute to @"ON" for that row.</li>
  </ol>
  
  <p>my simple code is:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
  
      NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
      cell.textLabel.text = [[object valueForKey:@"courseCode"] description];
      cell.detailTextLabel.text = [[object valueForKey:@"courseName"] description];
  UISwitch *theSwitch = [[UISwitch alloc]init];
  
      cell.accessoryView = theSwitch;
  
      NSLog(@"%@",[[object valueForKey:@"switchValue"] description]);
  
      if ([[[object valueForKey:@"switchValue"] description]isEqualToString: @"ON"]) {
  
          theSwitch.on = YES;
  
      }else{
  
          theSwitch.on = NO;
  
      }
  
  
      [theSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
  
      return cell;
  
  }
  </code></pre>
  
  <p>and the action is :</p>
  
  <pre><code>-(void) switchChanged: (UISwitch *) sender{
  
  
      NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
      NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
  
      if (sender.on) {
  
          How can I change the value?
  
      }else{
  
      }
  
  }
  </code></pre>