私は解決策を見つけました: DetailsView にデータを渡す前に、プロパティを追加し、このプロパティにデータを入れます。
前:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MyObject* myObj = (MyObject *)[self.managedObjectContext existingObjectWithID:[self.searchResults objectAtIndex:indexPath.row] error:nil];
DetailsViewController *details = [[DetailsViewController alloc] init];
details.myObject = myObj;
[self.navigationController pushViewController:details animated:YES];
}
後:
@property (nonatomic, strong) MyObject* myObj;
オブジェクトのプロパティを追加し、それをdidSelectRowAtIndexPath
メソッドに追加しました。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.myObj = (MyObject *)[self.managedObjectContext existingObjectWithID:[self.searchResults objectAtIndex:indexPath.row] error:nil];
DetailsViewController *details = [[DetailsViewController alloc] init];
details.myObject = self.myObj;
[self.navigationController pushViewController:details animated:YES];
}