关键是要用(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
的方法。 开始在你的ViewController创建一个公共属性(头文件):
@property (nonatomic) NSNumber *profileId;
保存由用户选择,当他摸到假,像这样的例子小区:
- (void)tableView:(UITableView *)tableView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"ToProfile" sender:indexPath];
}
然后
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSIndexPath* indexPath = (NSIndexPath *)sender;
SomeObject* tableViewItem = [self.data objectAtIndex:indexPath.row];
if ([[segue identifier] isEqualToString:@"ToProfile"]) {
ProfileViewController *profile = [segue destinationViewController];
profile.profileId = tableViewItem.profileId;
}
}
所以现在你可以从你的ViewController访问profileId属性。
来源
2015-08-16 10:11:04
Max
你有用户唯一对象ID的用户数据,同时转变? – rishi
这里有关于如何在目标vc上分配属性的很好的答案,但它们都建议分配给id属性。如果目标vc需要一个PFObject(可能),并且你有一个(可能)然后分配PFObject。 – danh