我有两个类(foodSelected,selectFood),在类SelectFood中我有一个代码,它接受用户单击的表行并发送一个NSString:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
foodSelected *food = [[foodSelected alloc] init];
NSString *selectedFood = [NSString stringWithFormat:@"Orange food"];
[food setFood:selectedFood];
[self.navigationController popViewControllerAnimated:YES];//Back to class foodSelected
}
已经在classSelected中,我有这个代码:
在.h档案中
@property (nonatomic,copy) NSString *foodSelected;
-(void)setFood:(NSString *)who;
在.m文件中:
@synthesize foodSelected;
-(void)setFood:(NSString *)who{
foodSelected = who;
NSLog(@"Food Received -> %@",who);//Show me (null)
}
显然我看不出有关我的代码的任何问题,但我不知道为什么setter方法正在接收null值,有人可以帮助我吗?
我想将一些值传递回调用视图控制器。