2014-05-21 73 views
1

我有一個問題,我沒有線索如何解決它。CLLocationCoordinate2DMake缺少類型說明符

我的代碼看起來像這樣

CLLocationCoordinate2D coord[12]; 
coord[0] = CLLocationCoordinate2DMake(52.5041,13.351); 

它說:

類型說明符缺少,默認爲 '廉政'

我不知道爲什麼。我嘗試了不同的想法,甚至在這個頁面上看到類似的代碼,當時我正在尋找一個提示。

GZ阿德里安

回答

0

根據文檔:

CLLocationCoordinate2D CLLocationCoordinate2DMake(CLLocationDegrees latitude, CLLocationDegrees longitude) 

而且

typedef double CLLocationDegrees; 

當你寫CLLocationCoordinate2DMake(52.5041,13.351);52.504113.351都可能不被視爲雙。

嘗試這樣的:

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc]init]; 
[numberFormatter setNumberStyle:kCFNumberFormatterDecimalStyle]; 
NSNumber *lat = [numberFormatter numberFromString:@"52.5041"]; 
NSNumber *lng = [numberFormatter numberFromString:@"13.351"]; 
coord[0] = CLLocationCoordinate2DMake(lat,lng); 
+0

,這12 diffrenet座標。對此沒有更好的方法嗎? – DaPole

+0

要爲12個不同的座標進行迭代,並且變量將是'String',它將變爲'double'。 – BriceB

+0

我覺得很蠢... 它沒有工作,因爲我在我的頭文件中試過。 現在把它放在locationManager中,它工作(第二行) – DaPole

相關問題