ios - How do I access the current annotation's NSString when in "prepareForSegue"? -
pin .h
#import <foundation/foundation.h> @import mapkit;  @interface pin : nsobject <mkannotation> {  nsstring *time; cllocationcoordinate2d coordinate; }  @property (nonatomic, copy)   nsstring *time; @property (nonatomic, assign) cllocationcoordinate2d coordinate;  @end  pin.m  #import "pin.h"  @implementation pin  @synthesize coordinate; @synthesize time; @end   how set pin in view
pin *newpin = [[pin alloc]init];             newpin.coordinate = usercoordinate;      nsdate *currenttime = [nsdate date];     nsdateformatter *dateformatter = [[nsdateformatter alloc] init];     [dateformatter setdateformat:@"mm-dd-yyy hh:mm a"];     nsstring *resultstring = [dateformatter stringfromdate: currenttime];     newpin.time = resultstring;     [self.mapview addannotation:newpin];   what happens when press callout
- (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)view calloutaccessorycontroltapped:(uicontrol *)control {     [self performseguewithidentifier:@"details" sender:view]; }  - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {       if ([segue.identifier isequaltostring:@"details"])      {         infoviewcontroller *vc = segue.destinationviewcontroller;      } }   now in second view controller accessed identifier "details", have nsstring hold time of specific pin. how can pass current pin's time nsstring next view's nsstring?
note: there multiple pins set @ different times on map , have tried passing data annotations detail view ios using storyboard , tried use
pin *an = (pin *)mapview.annotation;   but lets me used array mapview annotation
pin *an = (pin *)mapview.annotations;   please help!
you can access annotation via annotation property of annotation view , pass sender performseguewithidentifier so
- (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)view calloutaccessorycontroltapped:(uicontrol *)control {     [self performseguewithidentifier:@"details" sender:view.annotation]; }  - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {       if ([segue.identifier isequaltostring:@"details"])      {         pin *mypin=(pin *)sender;         infoviewcontroller *vc = segue.destinationviewcontroller;         vc.time=mypin.time;      } }      
Comments
Post a Comment