如何在故事板中使用prepareSegue方法?

时间:2014-11-20 10:20:52

标签: ios segue uistoryboardsegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
       NSIndexPath *indexPath = [self.myTableView indexPathForSelectedRow];
       ThirdViewController *destViewController = segue.destinationViewController;
        segue.destinationViewController displayTitlesArray = [[NSArray alloc]initWithObjects:@"first ",@"second",@"Third", nil ];}

显示标题数组是下一个视图控制器中的数组。但是我在这里得到错误。如何使用segue.destinationViewController对象将数据传递给下一个视图控制器。

1 个答案:

答案 0 :(得分:0)

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
       NSIndexPath *indexPath = [self.myTableView indexPathForSelectedRow];
       ThirdViewController *destViewController = (ThirdViewController  *)segue.destinationViewController;
       destViewController.displayTitlesArray = [[NSArray alloc]initWithObjects:@"first ",@"second",@"Third", nil ];}