1

In my application i am getting longitude,latitude and store values in server. When i print values directly i can get symbols(+ or -).After storing the values in float or NSString symbols are missing.any help will be appreciated.thanks in advance

currentLocation = newLocation;

if (currentLocation != nil) {
    longtiude = [NSString stringWithFormat:@"%f", currentLocation.coordinate.longitude];
    latitude= [NSString stringWithFormat:@"%f", currentLocation.coordinate.latitude];
}

 NSLog(@"New Lati%@, Long%@", latitude, longtiude);
4

1 回答 1

1

To always get a sign (+ or -) prepended to the converted number, add + to the format specifier:

NSString *s1 = [NSString stringWithFormat:@"%f %f", 1.3, -1.3];
// Output: 1.300000 -1.300000
NSString *s2 = [NSString stringWithFormat:@"%+f %+f", 1.3, -1.3];
// Output: +1.300000 -1.300000
于 2013-07-13T06:24:56.283 回答