Storyboard でセグエ (ShowADVDetail) を使用して、TableViewController セルから DetailViewContoller (UITableViewController) にデータを渡したいです。
解析された RSS フィードを含む NSMutableArray の「ストーリー」があります。
セルの「タイトル」値を渡す次の prepareForSegue を使用しています。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ShowADVDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
NSString *theTitle = [[stories objectAtIndex: storyIndex] objectForKey: @"title"];
[[segue destinationViewController] setDetailItem:theTitle];
}
}
次の行で、特定のセルの「タイトル」値を渡すことができます。
NSString *theTitle = [[stories objectAtIndex: storyIndex] objectForKey: @"title"];
次のように「説明」値と「リンク」値にアクセスすることもできます。
NSString *theDescription = [[stories objectAtIndex: storyIndex] objectForKey: @"description"];
NSString *theLink = [[stories objectAtIndex: storyIndex] objectForKey: @"link"];
しかし、セグエで 3 つの値すべてを渡すにはどうすればよいですか?
これまでのところ、私の didSelectRowAtIndexPath は次のようになっています。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO]
[self performSegueWithIdentifier:@"ShowADVDetail" sender:self];
}
これが理にかなっていることを願っています..
ありがとう