iphone - How to get current longitude and latitude in xcode simulator? -


this question has answer here:

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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -