我有一个应用程序,我试图选择程序依赖的资源(建筑,IT系统)。实体之间的关系是Resource.resourceusedonprog < < ---> Programme.usesresource。一片数据模型在这里: UITableView使用复选标记填充核心数据一对多关系 - CoreData:错误:严重的应用程序错误
我想在一个特定的程序使用资源的UITableViewController上使用多个复选标记选择。然而,当我尝试在表中的资源细胞相互作用的应用程序崩溃与错误
CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. The left hand side for an ALL or ANY operator must be either an NSArray or an NSSet. with userInfo (null)
我的代码如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Resource Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
Resource *resource = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSString *fullname = [NSString stringWithFormat:@"%@ %@", resource.hasmanager.firstname, resource.hasmanager.surname];
cell.textLabel.text = resource.name;
cell.detailTextLabel.text = fullname;
if (resource.resourceusedonprog == selectedProgramme){ cell.accessoryType = UITableViewCellAccessoryCheckmark;}
else {cell.accessoryType = UITableViewCellAccessoryNone;}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
Resource *resource = [self.fetchedResultsController objectAtIndexPath:path];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
resource.resourceusedonprog = NULL;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
resource.resourceusedonprog = selectedProgramme;
} }
的错误似乎是由资源被触发。 resourceusedonprog = selectedProgramme;和resource.resourceusedonprog = NULL;事件。如果我将它们注释掉,我可以检查并取消选中单元格(但显然,不会更改resource.resourceusedonprog的状态,即我试图实现的目标)。