iphone - How to get current longitude and latitude in xcode simulator? -
this question has answer here:
- set location in iphone simulator 10 answers
i trying current long , lat location getting both 0.0000, following code using
(cllocationcoordinate2d) getlocation{ cllocationmanager *locationmanager = [[[cllocationmanager alloc] init] autorelease]; locationmanager.delegate = self; locationmanager.desiredaccuracy = kcllocationaccuracybest; locationmanager.distancefilter = kcldistancefilternone; [locationmanager startupdatinglocation]; cllocation *location = [locationmanager location]; cllocationcoordinate2d coordinate = [location coordinate]; return coordinate; }
and call use:
cllocationcoordinate2d coordinate = [self getlocation]; nsstring *latitude = [nsstring stringwithformat:@"%f", coordinate.latitude]; nsstring *longitude = [nsstring stringwithformat:@"%f", coordinate.longitude]; nslog(@"*dlatitude : %@", latitude); nslog(@"*dlongitude : %@",longitude);
i added corelocation project. please advise me.
implement delegate method of location manager
- (void)locationmanager:(cllocationmanager *)manager didupdatetolocation: (cllocation *)newlocation fromlocation:(cllocation *)oldlocation
and can lat , lng using newlocation.coordinate.latitude
, newlocation.coordinate.longitude
and set current location in simulator can follow @ios_av
Comments
Post a Comment