詳細開示タップから詳細ビューコントローラにオブジェクトを渡すにはどうすればよいですか?これに対する推奨事項やクイックフィックスはありますか?理想的には、次のようなメソッドを作成したいと思います。
[self performSegueWithIdentifier:@"showDetail" sender:self passObject:object];
その理由は、「セグエの準備」は、詳細開示インジケーターの前のセルを押したときにのみ呼び出されるように見えるためです。以下のprepareの効果を作成するには、上記のようなメソッドをどのように作成しますか?
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
id object = [_objects objectAtIndex:indexPath.row];
[[segue destinationViewController] setDetailItem:object];
}
私はすでにそのようにUIStoryboardSegueのサブクラスを作成しようとしましたが、2つの問題が発生しました。
@implementation masterToDetail
-(void)performSegueWithIdentifier:(NSString*)identifier sender:(id)sender passObject:(id)object{
[self.destinationViewController setDetailItem:object];
[self performSegueWithIdentifier:identifier sender:sender];
}
-(void)performSegueWithIdentifier:(NSString*)identifier sender:(id)sender{
//What code should go here? Issue one
}
-(void)perform{
//Second issue, the compiler will crash and say I need to override perform.
}