2015-09-08 22 views
-3

我使用的是陣列使用AFHTTPRequestDCKeyValueObjectMapping解析JSON數據我可以得到SQL server的數據,並把它作爲數組訪問數組元素,並得到具體的數據,IOS

NSArray *chSpot = [parser parseArray:responseObject]; 

我所說的元素LocationLatLocationLong我想訪問它們並將它們打印出來

回答

1

我看到chSpot有3個對象,不知道你想要什麼(全部或一個)。無論如何,你可以在通過索引0(第一現場)獲得緯度,長斑:

ChangingSpots *spot = [chSpot objectAtIndex:0]; 
float lat = spot.LocationLat; 
float long = spot.LocationLong; 
+0

我還有一個小小的錯誤,這是我宣佈LocationLat和LocationLong作爲的NSString如何與兼容的數據類型進行更改注意NSInteger和NSNumber不可接受 –

+0

你想改變什麼? NSString - > float:'[str floatValue]';浮動到NSString:'[NSString stringWithFormat:@「%f」,floatValue]' – anhtu

+0

非常感謝你的工作 –