發送數據到API調用時有一個小問題,我有一個Array,它包含單個數組中的緯度和經度值,但是我的API不接受Array格式,因爲數組中的數據在字符串格式,但我的API只接受Double值如何在Swift中將Double值添加到NSMutableArray中
這裏我的示例代碼:
for (var i=0 ; i<startLocationArray.count;i++) {
let dictLatLong = startLocationArray[i] as! NSArray
print("dictLatLong==\(dictLatLong)")
for dict in dictLatLong
{
let arr: NSArray = dict as! NSArray
for subdict in arr
{
let arrLatLong = NSMutableArray()
let str = String(subdict.valueForKey("lng")! as! Double)+", "+String(subdict.valueForKey("lat")! as! Double)
arrLatLong.addObject(str)
self.outputArray.addObject(arrLatLong)
}
}
我的輸出是:
(
"80.2622228, 13.125962"
),
(
"80.2617606, 13.1259684"
),
(
"80.2617484, 13.1229377"
),
(
"80.2592969, 13.1229812"
),
(
"80.2594669, 13.118439"
)
我的預期outpu t是:
(
80.2622228, 13.125962
),
(
80.2617606, 13.1259684
),
(
80.2617484, 13.1229377
),
(
80.2592969, 13.1229812
),
(
80.2594669, 13.118439
)
從數組中刪除雙引號或如何將雙值添加到NsmutableArray中?
你似乎是力展開自選不少。別。你只是要求一個崩潰。請學習[如何正確處理它們](http://stackoverflow.com/a/36360605/2976878)。 – Hamish