I'm presenting a VC modally, then I dismiss it when a cell is selected along with call a method from the original VC.
The problem now is that nav
and routineTableViewController
NSLog as null.
How I present the model VC:
NSString *selectedRow = [[self.exerciseArray objectAtIndex:selectedRowIndex.row]objectForKey:@"exerciseName"];
UINavigationController *nav = self.parentViewController.navigationController;
RoutineDayTableViewController *routineDayTableViewController = (RoutineDayTableViewController *) [nav topViewController];
routineDayTableViewController.muscleURL = self.muscleURL;
[routineDayTableViewController addExercise];
[self.parentViewController dismissModalViewControllerAnimated:YES];
Hierarchy of VC: RoutineDayTableViewController -> presents Modally MusclesTableViewController, then pushes to child table view, which dismisses back to RoutineDayTableViewController.
Edit:
-(void)addExercise
{
PFObject *exerciseInRoutine = [[PFObject alloc] initWithClassName:@"exerciseInRoutine"];
[exerciseInRoutine setObject:self.selectedExercise forKey:@"name"];
[exerciseInRoutine setObject:self.muscleName forKey:@"muscle"];
[exerciseInRoutine setObject:self.muscleURL forKey:@"picture"];
[exerciseInRoutine saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
[self.tableView reloadData];
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}