I’m trying to pass 3 objects to another VC but they are showing up as Null in the destination VC.
VC1:
- (void)specificExerciseTableViewController:(SpecificExerciseTableViewController *)specificExerciseTableViewController didSelectSpecificExerciseWithURL:(NSString *)exerciseURL muscleName:(NSString *)muscleName muscleURL:(NSString *)muscleURL;
{
[self addExercise];
}
-(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]);
}
}];
}
The class that is passing the objects to VC1:
if ([self.delegate respondsToSelector:@selector(specificExerciseTableViewController:didSelectSpecificExerciseWithURL:muscleName:muscleURL:)])
{
NSString *exerciseName = [[self.exerciseArray objectAtIndex:selectedRowIndex.row] objectForKey:@"exerciseName"];
[self.delegate specificExerciseTableViewController:self didSelectSpecificExerciseWithURL:exerciseName muscleName:self.muscleName muscleURL:self.muscleURL];
[self dismissModalViewControllerAnimated:YES];
}
Edit:
I’ve updated my method to set the objects to the VC’s properties, but have same problem:
- (void)specificExerciseTableViewController:(SpecificExerciseTableViewController *)specificExerciseTableViewController didSelectSpecificExerciseWithURL:(NSString *)exerciseURL muscleName:(NSString *)muscleName muscleURL:(NSString *)muscleURL;
{
self.muscleName = exerciseURL;
self.muscleName = muscleName;
self.muscleURL = muscleURL;
[self addExercise];
}
What do you expect to happen when you execute the code shown above?
You second code block calls
-specificExerciseTableViewController:didSelectSpecificExerciseWithURL:muscleName:muscleURL:on somedelegatebut the implementation of that method in your “VC1” example ignores the arguments passed to that method. You don’t seem to be doing anything with the data you are given.