我正在开发一个包含menuViewController(tableViewController)的应用程序,该应用程序有一个名为“profileCell”的单元,显示用户的名字,可以从另一个viewController“userViewController”导入,该用户的名字属性从登录Facebook或Twitter或谷歌plus.My的问题是,属性firstName不是空的“userViewController”,但当我想要在menuViewController中访问它,它返回一个null.I已经在网上搜索,我也看到了其他类似的问题,但我无法解决我的问题。如何从iOS的其他视图控制器访问属性?
这是我的代码:
case 2 : {
NSString *cellIdentifier = [[NSString alloc] initWithFormat:@"profileCell"];
profileTableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
UserViewController *userVC = [[UserViewController alloc]init];
cell.cellNameLabel.text = [NSString stringWithFormat:@"%@",userVC.firstName];
return cell;
break;
}
是的,谢谢,我会做到的。 – loussario
我是否选择NSUserDefaults或NSkeyedArchiver? – loussario
NUUserDefaults在您的用例中更有意义我认为 – indrajit