1

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];
}
mozkarakoc
  • 269
  • 6
  • 14

2 Answers2

1

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.

Magic Bullet Dave
  • 9,006
  • 10
  • 51
  • 81
  • Thank you very much. I can not see this is a problem,I change it but the problem not solved. Solving the problem by changing the parameter " appDelegate.selectedGroupId " sent the same view I conducted in the different methods. sorry my bad english, thanks again. – mozkarakoc Jul 17 '12 at 08:08
  • Can you post your Groups class definition and I'll have a look. – Magic Bullet Dave Jul 17 '12 at 08:27
0

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];
}
iOS Test
  • 1,103
  • 1
  • 11
  • 18
  • Earlier you have used: Groups *tmpGroups = [[Group alloc] init]; now Groups *tmpGroups = [[Groups alloc] init]; Groups/Group is the difference – iOS Test Jul 17 '12 at 08:30