targeting a view controller within another view controller

Discussion in 'iOS Programming' started by johnmerlino, Jul 23, 2012.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    Usually, when I want to set the variable of another view controller within a specific view controller, I do this:

    Code:
     - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
     {
               MyOtherViewController *_vc = [segue destinationViewController]; 
              [_vc setUser:current_user];
    }
    
    Now here's my problem. I am not using the prepareForSegue method in the case where a user clicks an annotation on mapkit:

    Code:
    - (void)mapView:(MKMapView *)mapView 
     annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
        
        NSLog(@"my current report is %@", view.annotation);
    
        if ([(UIButton*)control buttonType] == UIButtonTypeDetailDisclosure){
            [self performSegueWithIdentifier:@"ShowRemoteDetailViewManagerController" sender:self];        
        }
    }
    
    So in the above case, I have no access to a segue parameter to target the destination controller to set the view.annotation as the value of one of its methods. So how would I target the destination controller in the above example?

    thanks for response
     
  2. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    I'm assuming both methods listed are in the same view controller. Is that true? If true then from reading the docs, you should still be using prepareForSegue:sender:. Does that not work?

    P.S. I haven't played with seques yet. You question just looked interesting. :)
     

Share This Page