我的代码是:
- (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中显示“string”。 有什么帮助吗?
答案 0 :(得分:2)
您需要向目标视图控制器添加属性以设置所需的字符串。然后,您将能够从目标视图控制器引用其值:
@interface DestinationViewController
...
@property (nonatomic, readwrite) NSString *theString;
@end
现在你可以打电话了
[[segue destinationViewController] setTheString:string];
或
DestinationControllerType *dest = [segue destinationViewController];
dest.theString = string;
然后在目标视图显示时引用theString
。