Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to select one TableViewCell and set all the other Cells to the Bool Value NO in CoreData?
    primarykey
    data
    text
    <p>i have a list of tables,saved in core data with a bool value, when i select a cell the bool value is saved to YES in core data. but when i select one more than one Cell, 2 cells are on YES. i just want to set 1 cell to be yes. how can i do that. here is my code: </p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { BestuhlungCell *cell =(BestuhlungCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"]; NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.bestuhlungLabel.text = [managedObject valueForKey:@"bestuhlungstitel"]; NSData *data = [[NSData alloc] initWithData:[managedObject valueForKey:@"bestuhlungsfoto"]]; UIImage *image = [UIImage imageWithData:data]; cell.bestuhlungFoto.image = image; cell.checkButton.hidden=YES; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSManagedObjectContext *context = [app managedObjectContext]; // BestuhlungCell *cell = (BestuhlungCell *)[tableView cellForRowAtIndexPath:indexPath]; Bestuhlung *bestuhlung=[self.fetchedResultsController objectAtIndexPath:indexPath]; if ([[bestuhlung valueForKey:@"check"] boolValue]) { [bestuhlung setValue:[NSNumber numberWithBool:NO] forKey:@"check"]; } else { [bestuhlung setValue:[NSNumber numberWithBool:YES] forKey:@"check"]; } NSError *error = nil; if (![context save:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } [self.navigationController popViewControllerAnimated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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