1
votes

I have a tableView and I create a Button on one cell.

UIButton *deleteGroupButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [deleteGroupButton setFrame:CGRectMake(218, 12, 40, 60)];
    [deleteGroupButton addTarget:self action:@selector(deleteGroupButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

When I click to button, an Exception occur with that message:

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Group deleteGroup:]: unrecognized selector sent to instance 0x5a8afc0' "

And that is my deleteGroupButtonClicked method

- (void) deleteGroupButtonClicked: (id) sender {    

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

2 Answers

1
votes

You have something slightly odd in your deleteGroupButtonClicked: method,

You have a object of class Groups but you are alloc'ing an object of class Group. I am guessing Groups is a collection of Group objects. In which case a deleteGroup: method would only exist in the Groups class.

0
votes

Just replace your deleteGroupButtonClicked method with the following:

- (void) deleteGroupButtonClicked: (id) sender 
{    

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