我正在使用委托来获取用户在表格视图中选择的选项,但我不断收到如下错误:
2012-05-12 23:26:06.704 test [4629:fb03] - [AddContentViewController catPickViewController:didSelectGame:]:无法识别的选择器发送到实例0x6d79ed0
我在表格视图中记录了该选项,但无法在第一个视图中记录该选项。
这就是我在表格视图中的内容
- (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];
}
这就是我对select方法的看法:
- (void)CatPickViewController:(CatPickViewController *)controller didSelectGame:(NSString *)theGame
{
NSLog(@"%@",theGame);
category = theGame;
self.catDetails.text = category;
[self.navigationController popViewControllerAnimated:YES];
}
我知道问题出在[self.delegate catPickViewController:self didSelectGame:theGame];
但我该怎么办呢?
我忘了提到我有catPickViewController.h喜欢
@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
所以你们提到的catPickViewController来自这里
答案 0 :(得分:2)
您正在呼叫catPickViewController
,但方法名称拼写为CatPickViewController
。您应该将其更改为catPickViewController
。