I am using delegate to get an option that user choosed in a table view but I constantly receive a error like below:
2012-05-12 23:26:06.704 test[4629:fb03] -[AddContentViewController catPickViewController:didSelectGame:]: unrecognized selector sent to instance 0x6d79ed0
I logged the option in the table view and can’t log it in my first view.
This is what I have at the table view
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (selectedIndex != NSNotFound)
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:selectedIndex inSection:0]];
cell.accessoryType = UITableViewCellAccessoryNone;
}
selectedIndex = indexPath.row;
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
NSString *theGame = [games objectAtIndex:indexPath.row];
NSLog(@"%@",theGame);
[self.delegate catPickViewController:self didSelectGame:theGame];
}
and this is what I have for the select method:
- (void)CatPickViewController:(CatPickViewController *)controller didSelectGame:(NSString *)theGame
{
NSLog(@"%@",theGame);
category = theGame;
self.catDetails.text = category;
[self.navigationController popViewControllerAnimated:YES];
}
I knew the problem is with [self.delegate catPickViewController:self didSelectGame:theGame];
but what shall I do with it?
I forgot to mention that I have catPickViewController.h like
@class CatPickViewController;
@protocol CatPickViewControllerDelegate <NSObject>
- (void)catPickViewController:(CatPickViewController *)controller didSelectGame:(NSString *)game;
@end
@interface CatPickViewController : UITableViewController
@property (nonatomic, weak) id <CatPickViewControllerDelegate> delegate;
@property (nonatomic, strong) NSString *game;
@end
so catPickViewController as you guys mentioned is from here
You are calling
catPickViewController, but the method name is spelledCatPickViewController. You should change that tocatPickViewController.