1

我的代码是:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
 {
    if ([[segue identifier] isEqualToString:@"showDetail"]) {

       NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
       NSString *string = [feeds[indexPath.row] objectForKey: @"description"];
       NSLog(@"Description : %@" , string);

        [[segue destinationViewController] " WHAT TO CODE IN HERE ? "];

    } }

我需要在 viewController 的 NSLog 中显示“字符串”。有什么帮助吗?

4

1 回答 1

2

您需要向目标视图控制器添加一个属性来设置所需的字符串。然后你就可以从目标视图控制器中引用它的值:

@interface DestinationViewController
...
@property (nonatomic, readwrite) NSString *theString;
@end

现在你可以打电话

[[segue destinationViewController] setTheString:string];

或者

DestinationControllerType *dest = [segue destinationViewController];
dest.theString = string;

然后theString在目标视图出现时参考。

于 2013-07-23T17:48:56.820 回答