Hello all, Ive been working on a list app where core data is used to persist a checkmark Everything was fine till xcode crashed. No code was changed but now instead of a checkmark showing up immediatly you have to click the row, quit the app, then relaunch it to get anything. This is the code along with an other question of how I got the code in the first place. http://stackoverflow.com/questions/2215465/how-can-a-checkmark-state-be-saved-in-core-data
Any help is greatly appreciated. Thanks
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *selectedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
if ([[selectedObject valueForKey:@"check"] boolValue]) {
[selectedObject setValue:[NSNumber numberWithBool:NO] forKey:@"check"];
} else {
[selectedObject setValue:[NSNumber numberWithBool:YES] forKey:@"check"];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *defaultCellIdentifier = @"Item";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:defaultCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:defaultCellIdentifier] autorelease];
}
NSManagedObject *item = [[self fetchedResultsController] objectAtIndexPath:indexPath];
cell.textLabel.text = [item valueForKey:@"name"];
if ([[item valueForKey:@"check"] boolValue]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
-(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accesoryTypeForRowWithInddexPath:(NSIndexPath *)indexPath {
return UITableViewCellAccessoryNone;
}