I have a parent view (table) that passes a detail object to the child view (table).
The parent view has a network request that gets data and passes data to the child view.
I want to be able to update the data when I’m in the child view. I think I need to call the parent view’s network request method while viewing the child view, and update the child table. Is this possible?
In Parent VC:
- (void)fetchAppointmentsForVisibleDate {
self.appointmentArray = [DataSource getTodayData:self.visibleDate];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:50];
for (NSDictionary *appointment in self.appointmentArray)
{
[array addObject: [NSString stringWithFormat:@"%@: %@", [appointment objectForKey:@"scheduled_time"], [appointment objectForKey:@"patient"]]];
}
self.listData = array;
[self.appointmentTableView reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ChildVC *vc = [Child VC alloc]initWithNib@"ChildVC"];
vc.appointmentDictionary = [self.appointmentArray objectAtIndex:path.row];
}
Is your network request is bound to be called by parent view.
If its just a method you can set the delegate of your child to the parent.
i.e in the parent view you can do
create child object and just do
and call your network method from child
i.e [delegate networkMethod];