ios - didUpdateToLocation is never called -


i want pass information location of user function uses it. delegate class mylocation singleton stores information.

but in code didupdatetolocation never gets called . should n't called @ least once whenever startupdatinglocation called if device stationary?

i did check if locationmanager.location.coordinate.latitude , locationmanager.location.coordinate.longitude have right values , do. location services enabled , user permission access location services granted. still building ios 5. none of given solutions seem work me!

can please give me idea why not working?

the code follows:

cllocationmanager *locationmanager; clgeocoder *geocoder; clplacemark *placemark;  @implementation mylocation { }  + (id)getinstance {     static mylocation *sharedmylocation = nil;     static int i=0;     if(i==0){         sharedmylocation = [[mylocation alloc] init];         i=1;     }     return sharedmylocation; }     - (id)init {     if (self = [super init]) {         latitude = [[nsstring alloc] init];         longitude = [[nsstring alloc] init];         country = [[nsstring alloc] init];         admin_area = [[nsstring alloc] init];         postal_code = [[nsstring alloc] init];         locality = [[nsstring alloc] init];         subtfare = [[nsstring alloc] init];         tfare = [[nsstring alloc] init];     }     return self; }  - (void) startupdate{     if(locationmanager == nil)     {         locationmanager = [[cllocationmanager alloc] init];         locationmanager.delegate = self;         locationmanager.desiredaccuracy = kcllocationaccuracybest;     }     if(geocoder == nil)        geocoder = [[clgeocoder alloc] init];       [locationmanager startupdatinglocation];     }   - (void)locationmanager:(cllocationmanager *)manager didfailwitherror:(nserror *)error   {     nslog(@"didfailwitherror: %@", error); }  - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation        *)newlocation fromlocation:(cllocation *)oldlocation {     nslog(@"didupdatetolocation: %@", newlocation);     cllocation *currentlocation = newlocation;      if(currentlocation != nil){         longitude = [nsstring stringwithformat:@"%.8f",   currentlocation.coordinate.longitude];         latitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.latitude];     }      [locationmanager stopupdatinglocation];      // reverse geocoding     nslog(@"resolving address");     [geocoder reversegeocodelocation:currentlocation completionhandler:^(nsarray *placemarks, nserror *error) {         nslog(@"found placemarks: %@, error: %@", placemarks, error);         if (error == nil && [placemarks count] > 0) {             placemark = [placemarks lastobject];             country = [nsstring stringwithformat:@"%@",placemark.country];             admin_area = [nsstring stringwithformat:@"%@",placemark.administrativearea];             postal_code = [nsstring stringwithformat:@"%@",placemark.postalcode];             locality = [nsstring stringwithformat:@"%@",placemark.locality];             subtfare = [nsstring stringwithformat:@"%@",placemark.subthoroughfare];             tfare = [nsstring stringwithformat:@"%@",placemark.thoroughfare];         } else {             nslog(@"%@", error.debugdescription);         }     } ]; }   - (nsstring*)  getlatitude {     return latitude; }   - (nsstring*) getlongitude {     return longitude; }  - (nsstring*) getcountry {     return country; }  - (nsstring*) getadminarea {     return admin_area; }  - (nsstring*) getpostalcode {     return postal_code; }  - (nsstring*) getlocality {     return locality; }  - (nsstring*) getsubtfare {     return subtfare; }   - (nsstring*) gettfare {     return tfare; }   error gps_interface::getlatitude(char* buffer , unsigned int len) {     id temp = [mylocation getinstance];     [temp startupdate];     nsstring* tempbuf = [temp getlatitude];     nsstring *l = [nsstring stringwithformat:@"%@",tempbuf];     const char* lati= [l utf8string];     if(strlen(lati) < len)         std::strncpy(buffer,lati,[l length]);     else          return buffer_insufficent;      return no_error;  } /* other similar getter functions! */ 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -