我有一个 tableView,我在一个单元格上创建了一个 Button。
UIButton *deleteGroupButton = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteGroupButton setFrame:CGRectMake(218, 12, 40, 60)];
[deleteGroupButton addTarget:self action:@selector(deleteGroupButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
当我点击按钮时,该消息出现异常:
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Group deleteGroup:]: unrecognized selector sent to instance 0x5a8afc0' "
那是我的 deleteGroupButtonClicked 方法
- (void) deleteGroupButtonClicked: (id) sender {
Groups *tmpGroups = [[Group alloc] init];
NSInteger tmp = appDelegate.selectedGroupId;
[tmpGroups deleteGroup:tmp];
[tmpGroups release];
}
最佳答案
您的 deleteGroupButtonClicked: 方法有些奇怪,
您有一个类 Groups
的对象,但您正在分配一个类 Group
的对象。我猜 Groups
是 Group
对象的集合。在这种情况下,deleteGroup:
方法将仅存在于 Groups
类中。
关于iphone - NSInvalidArgumentException ||发送到实例的无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11518152/