NSInvalidArgumentException accessing NSMutableArray in a UITableView
- by kashar28
Hello,
I am a noob in iPhone programming so kindly guide me. I have 5 buttons in a custom UITableViewCell. Following is the code to determine which button was pressed.
In ProductTableCustomCell.m
-(IBAction) getRating:(id) sender {
ProductTableView *ptv = (ProductTableView *)self.superview;
if((UIButton *) sender == box1) {
[ptv.totalComments addObject:@"BOX2"];
} else if((UIButton *) sender == box2){
NSLog(@"Box2");
[ptv.totalComments addObject:@"BOX2"];
NSLog(@"Am I here?");
}else if((UIButton *) sender == box3){
NSLog(@"Box3");
[ptv.totalComments addObject:@"BOX3"];
}else if((UIButton *) sender == box4){
NSLog(@"Box4");
[ptv.totalComments addObject:@"BOX4"];
}else if((UIButton *) sender == box5){
NSLog(@"Box5");
[ptv.totalComments addObject:@"BOX5"];
}
}
Here totalComments is a NSMutableArray in ProductTableView which is a UITableView. If for example I click button2, then I get the following error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UITableView totalComments]: unrecognized selector sent to instance 0x4036e00'**
I don't understand the problem. I have double checked the IBOutlets and IBActions as well. Everything seems proper. I think the problem is in the superview.Any help would be appreciated.