我使用代理來獲得一個選項,用戶選用表中的觀點,但我不斷收到一個錯誤象下面這樣:無法識別的選擇發送到實例0x6d79ed0
2012-05-12 23:26:06.704的測試[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];
}
,這是我的選擇方法:
- (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提到你們從這裏
方法簽名幾乎從不以大寫字母開頭。 – CodaFi
在調用'catPickViewController'(在'didSelectRowAtIndexPath:'底部附近)之前記錄'self.delegate'的值並查看它說了什麼。 –