Reputation: 277
HI all,
I was using a sample code which uses CLLocationManager class to determine the current location of user. when i run this app on iPad i am getting the correct location but when i run the same app on iPod Touch i am getting a blank label i.e nothing is displayed on the label .although wi-fi signal strength is good in both iPod and iPad.The code looks like...
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
latLabel.text = lat;
[latLocationArray addObject:lat];
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
longLabel.text = longt;
[longLocationArray addObject:longt];
}
Upvotes: 1
Views: 395
Reputation: 14376
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
You're aware that all these machinations have a net result of '0' when newLocation.coordinate.latitude >= 0, correct?
if newLocation.coordinate.latitude = 90.....
degrees = 90
decimal = 0; (90 - 90)
minutes = 0; (0 * 60)
seconds = 0; (0 * 3600 - 0 * 60) // assuming typical operand precedence
Upvotes: 0
Reputation: 113767
It's possible that the iPad is seeing WiFi stations that the iPod Touch can't see. The Touch has a smaller WiFi range. Are you testing in an area with very few WiFi stations (the countryside).
Is the iPad a 3G model? If it is, it will use GPS and cell towers if WiFi isn't working.
Have you checked any errors that the location manager is sending back to you? You might have disabled location data for the app previously, or there may be some other error.
Upvotes: 1