当我添加核心数据新关系时,我有这个错误。我在互联网上阅读了很多资源,但他们无法帮助我...也许你可以...... 这是我的代码,然后我添加了关系:
std = [NSEntityDescription insertNewObjectForEntityForName:@"Student" inManagedObjectContext:self.context];
std.fio = fio.text;
std.phone = phone.text;
NSError *error;
self.selectedGroups = MSGTVC.selectedGroups;
for(Group *info in self.selectedGroups){
[std addGroupsObject:info];
} if (![self.context save:&error]) {
NSLog(@"Cant Save: %@", [error localizedDescription]); }
in line [std addGroupsObject:info];是错误:
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [group countByEnumeratingWithState:objects:count:]:无法识别的选择器发送到实例0x816a1c0'
这是我的代码,然后我为selectedGroups赋值:
NSArray *indexselected = [[NSArray alloc] initWithArray:[self.tableView indexPathsForSelectedRows
__OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0)]];
for (NSIndexPath *into in indexselected)
{
self.selectedGroups = [self.group objectAtIndex:into.row];
}
如果你能帮助解决这个问题,我会很高兴,谢谢你。