2013-07-13 28 views
1

在我的應用程序中,我獲取服務器中的經度,緯度和商店值。 當我打印值直接,我可以得到的符號(+或 - )。在浮動或符號NSString的存儲值均missing.any幫助將提前appreciated.thanks用標誌符號獲取經度和緯度

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); 
+0

你需要表現出與問題相關的代碼。顯示如何檢索並顯示問題值。 – rmaddy

+0

你會得到什麼輸出和你期望的輸出? –

+0

我越來越像13.3332.但我需要像+13.3332 – Xcode

回答

1

要始終得到一個符號( +-)前置到轉換後的數字,加+于格式說明:

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