Pomiń dane między kontrolerem widoku segue [duplikat]
To pytanie jest dokładną kopią:
jak przekazywać obiekty między kontrolerami widoku 2 odpowiedzi Mój kontroler pierwszego widoku,AllAthletes
jest widocznym widokiem wszystkich moich podstawowych jednostek danych. Wyświetla jednostkę „sportowiec” i jej właściwości w komórce tabeli stylu napisów, takiej jak imię itp. Po kliknięciu komórki widoku chcę, aby ten kontroler widoku przekazał informacje o wybranej jednostce, ale „ Nie jestem pewien, jak przekazać te informacje (obiekt zarządzany, encja, właściwości itp. ścieżki indeksu) do kontrolera widoku szczegółów. Czy ktoś mógłby wskazać mi właściwy kierunek?
allathletes.m
-(void)viewWillAppear:(BOOL)animated{
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
_managedObjectContext = [appDelegate managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *athlete = [NSEntityDescription entityForName:@"Athlete" inManagedObjectContext:_managedObjectContext];
[request setEntity:athlete];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"first" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc]initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[_managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil){
//handle error
}
[self setAthleteArray:mutableFetchResults];
[self.tableView reloadData];
}
//this is what I have so far
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"setAthlete"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
AthleteDetail *destViewController = segue.destinationViewController;
}
}
//i was also thinking something like this?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIViewController* detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
NSMutableString *object = thisArray[indexPath.row];
detailViewController.passedData = object;
[self.navigationController pushViewController:detailViewController animated:YES];
}
Drugim kontrolerem, do którego cię popycha, jest AthleteDetail. Dziękuję za Twój czas