iphone - CLLocation getting EXC_BAD_ACCESS -
i getting error when trying access cllocation, can please explain why?
cllocation *currentlocation; @property (nonatomic, retain) cllocation *currentlocation;
i geeting feedback location location manager:
- (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { if (newlocation != nil) { currentlocation = newlocation; nslog(@"locationmanager: %@", currentlocation); } }
locationmanager: <+36.45307493, +28.22220462> +/- 100.00m (speed -1.00 mps / course -1.00) @ 9/2/11 10:14:58 π.μ. gmt+02:00
but when trying access currentlocation didselectannotationview exc_bad_access:
- (void)mapview:(mkmapview *)mapview didselectannotationview:(mkannotationview *)view { nslog(@"current location: %@", currentlocation); }
can please explain why cannot access it?
many thanks!
you not retaining location. like:
- (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { if (newlocation != nil) { self.currentlocation = newlocation; /// change here nslog(@"locationmanager: %@", currentlocation); } }
Comments
Post a Comment