Uitableview 将JSON数据传递给另一个视图

Uitableview 将JSON数据传递给另一个视图,uitableview,ios7,jsonmodel,Uitableview,Ios7,Jsonmodel,我有一个从web加载JSON内容的TableView。 我使用AFNetworking和JSONModel。我使用本教程来接收和解析数据 这是代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"CellIdentifier";

我有一个从web加载JSON内容的TableView。 我使用AFNetworking和JSONModel。我使用本教程来接收和解析数据 这是代码

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *identifier = @"CellIdentifier";
        __weak ProgramacaoTableCell *cell = (ProgramacaoTableCell *)[self.tableView dequeueReusableCellWithIdentifier:identifier];

        ProgramacaoModel* programacao = _programacao.programacaoArray[indexPath.row];

        // NameLabel is the Label in the Cell.
        cell.nameLabel.text = [NSString stringWithFormat:@"%@", programacao.atracao ];

        return cell;

    }
我想知道如何将此数据传递给详细视图控制器。 在我的DetailViewController中,我具有接收数据的属性

@property (nonatomic, strong) IBOutlet UILabel *programacaoNomeLabel;

您可以通过导航访问控制器:

NSArray* vcStack=[self appDelegate].myNavigationController.viewControllers;
UIViewController* vcUnder;
if(vcStack.count > 0)
    vcUnder=[vcStack objectAtIndex:(vcStack.count-1)];
// -1 depends when you called your controller that's why we test the kind of class
if([vcUnder isKindOfClass:[DetailViewController class]]){
    ((DetailViewController*) vcUnder). programacaoNomeLabel = @"some data";
}
我找到了答案

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Pass the selected object to the new view controller.

    if ([[segue identifier] isEqualToString:@"pushDetalhesView"]) {

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

        // Pega o objeto da linha selecionada
        ProgramacaoModel *object = [_programacao.programacaoArray objectAtIndex:indexPath.row];
        // Pass the content from object to destinationViewController
        [[segue destinationViewController] getProgramacao:object];

    }

}
在my Details ViewController中,我创建了一个iVar

@interface ProgramacaoDetalhesViewController ()
{
    ProgramacaoModel *_programacao;
}
并设置两个方法,一个用于接收内容,另一个用于设置标签

- (void) getProgramacao:(id)programacaoObject;
{
    _programacao = programacaoObject;
}

- (void) setLabels
{
    programacaoNomeLabel.text = _programacao.atracao;

}

这与JSON有什么关系?@HotLicks我用JSON填充内容。但是,给定内容,它与来自JSON和来自其他来源有什么区别?你的问题似乎与JSON无关。是的,我之所以提到这个@HotLicks,是因为可能有人觉得有必要提及它。但是已经找到了答案,谢谢