Iphone NSInvalidArgumentException | |未识别的选择器已发送到实例

Iphone NSInvalidArgumentException | |未识别的选择器已发送到实例,iphone,ios,xcode,invalidargumentexception,Iphone,Ios,Xcode,Invalidargumentexception,我有一个tableView,我在一个单元格上创建了一个按钮 UIButton *deleteGroupButton = [UIButton buttonWithType:UIButtonTypeCustom]; [deleteGroupButton setFrame:CGRectMake(218, 12, 40, 60)]; [deleteGroupButton addTarget:self action:@selector(deleteGroupButtonClicked:)

我有一个tableView,我在一个单元格上创建了一个按钮

UIButton *deleteGroupButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [deleteGroupButton setFrame:CGRectMake(218, 12, 40, 60)];
    [deleteGroupButton addTarget:self action:@selector(deleteGroupButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
当我单击“到”按钮时,该消息出现异常:

“由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:“-[Group deleteGroup:]: 已将无法识别的选择器发送到实例0x5a8afc0'”

这就是我的deleteGroupButtonClicked方法

- (void) deleteGroupButtonClicked: (id) sender {    

    Groups *tmpGroups = [[Group alloc] init];
    NSInteger tmp = appDelegate.selectedGroupId;
    [tmpGroups deleteGroup:tmp];
    [tmpGroups release];
}

您的deleteGroupButtonClicked:method有点奇怪


您有一个class
Groups
对象,但您正在分配class
Groups
对象。我猜
对象的集合。在这种情况下,
deleteGroup:
方法将只存在于
类中。

您的deletegroupbutonclick:method中有点奇怪


您有一个class
Groups
对象,但您正在分配class
Groups
对象。我猜
对象的集合。在这种情况下,
deleteGroup:
方法将只存在于
类中。

只需将deletegroupbutonclicked方法替换为以下方法:

- (void) deleteGroupButtonClicked: (id) sender 
{    

Groups *tmpGroups = [[Groups alloc] init];
NSInteger tmp = appDelegate.selectedGroupId;
[tmpGroups deleteGroup:tmp];
[tmpGroups release];
}

只需将deleteGroupButtonClicked方法替换为以下方法:

- (void) deleteGroupButtonClicked: (id) sender 
{    

Groups *tmpGroups = [[Groups alloc] init];
NSInteger tmp = appDelegate.selectedGroupId;
[tmpGroups deleteGroup:tmp];
[tmpGroups release];
}

非常感谢你。我看不出这是一个问题,我改变了它,但问题没有解决。通过更改参数“appDelegate.selectedGroupId”来解决问题,发送了我用不同方法执行的相同视图。对不起,我的英语不好,再次谢谢。你可以发布你的小组课程定义,我会看一看。非常感谢。我看不出这是一个问题,我改变了它,但问题没有解决。通过更改参数“appDelegate.selectedGroupId”来解决问题,发送了我用不同方法执行的相同视图。对不起,我的英语不好,再次感谢。你能发布你的组类定义吗?我来看看。之前你用过:Groups*tmpGroups=[[groupalloc]init];现在Groups*tmpGroups=[[Groups alloc]init];Groups/Group是您之前使用的差异:Groups*tmpGroups=[[Group alloc]init];现在Groups*tmpGroups=[[Groups alloc]init];组/组的区别是什么