Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何将对象从单元传递到新控制器_Ios_Uiviewcontroller_Uitableview_Uistoryboardsegue - Fatal编程技术网

Ios 如何将对象从单元传递到新控制器

Ios 如何将对象从单元传递到新控制器,ios,uiviewcontroller,uitableview,uistoryboardsegue,Ios,Uiviewcontroller,Uitableview,Uistoryboardsegue,对于我的UITableView中的每个单元格,我设置了一个自定义对象。像这样: // Reference to the turn PFObject *turnToPlay = [self.currentUserTurnsToPlay objectAtIndex:indexPath.row]; 选择单元格后,我需要将该对象传递给新的视图控制器 这是我的didSelectRowAtIndexPath if (indexPath.section == 0) { [self performSe

对于我的
UITableView
中的每个单元格,我设置了一个自定义对象。像这样:

// Reference to the turn
PFObject *turnToPlay = [self.currentUserTurnsToPlay objectAtIndex:indexPath.row];
选择单元格后,我需要将该对象传递给新的视图控制器

这是我的
didSelectRowAtIndexPath

if (indexPath.section == 0) {
    [self performSegueWithIdentifier:@"takeGameTurn" sender:self];  
}
我正在努力找出如何引用为单元格创建的PFObject,将其传递给目标视图控制器。我知道我会将其传递到
prepareforsgue
中,但如何从单元格选择中获取对象


我从
didSelectRowAtIndexPath
中引用了indexath,但是如何将其传递到segue目标控制器?就好像我在那个方法中需要另一个参数。

在您的PrepareForegue中

  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
         if ([segue.identifier isEqualToString:@"takeGameTurn"]){
               NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
               PFObject *turnToPlay = [self.currentUserTurnsToPlay objectAtIndex:indexPath.row];

          }
    }

单元格的PFObject属性是什么?如果是的话,你可以

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"takeGameTurn"])
    {
        YourNextViewController *nextVC = [segue destinationViewController];
        NSIndexPath *indexPath;
        indexPath = [myTableView indexPathForSelectedRow];
        MyCustomCell *cell = (MyCustomCell *)[myTableView cellForRowAtIndexPath:indexPath];
        nextVC.myPFObject = cell.assignedPfObject;


    }
}

谢谢,需要在ExpathForSelectedRow中使用,我不知道这是可用的。