iphone - NSInvalidArgumentException ||发送到实例的无法识别的选择器

标签 iphone ios xcode invalidargumentexception

我有一个 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 的对象。我猜 GroupsGroup 对象的集合。在这种情况下,deleteGroup: 方法将仅存在于 Groups 类中。

关于iphone - NSInvalidArgumentException ||发送到实例的无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11518152/

相关文章:

iphone - 获取整个 UITableViewCell 的宽度/框架

ios - 如何创建登录条件和核心数据表值不能存储两次

php - iPhone 收不到推送通知

iphone - 尝试在 iOS 上实现 JW Player

ios - Sprite 出现在模拟器中,而不是设备上

ios - 部署目标为 5.x 的 Xcode5.1.1?

iphone - UITabBarItem 图标动画

ios - 使用 Core Data 将图像添加到数据库

ios - 如何将项目签名证书设置为“无”?

objective-c - 访问使用 xcode/cocoa 创建的应用程序包中的资源