I am trying to send data from a container (child view) to the parent. In another view controller, I was able to send data from parent to child using
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
However, I'm not sure how to send data from the child to the parent, in particular, I'm trying to send the userLat property, which is a container property, to the parent property. Any tips?
PinViewController.m (parent):
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"children : %@", self.childViewControllers);
NSLog(@"children : %@", self.childViewControllers.userLat);
}
MapWithinPinViewController (child, container)
- (void)viewDidLoad
{
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.delegate = self;
self.view = mapView_;
}
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);
[mapView_ clear];
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(coordinate.latitude, coordinate.longitude);
self.userLat = @"test";
marker.map = mapView_;
}
source
share