如何在swift中将Double值添加到NSMutableArray中

时间:2016-04-11 06:30:36

标签: ios swift nsmutablearray

我向API调用发送数据时遇到小问题,我有一个数组,它包含单个数组中的纬度和经度值,但我的API不接受数据格式,因为数组中的数据是字符串格式但我的API只接受双值

这里是我的示例代码:

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)
                        }

                    }

我的OutPut是:

(
    "80.2622228, 13.125962"
),
    (
    "80.2617606, 13.1259684"
),
    (
    "80.2617484, 13.1229377"
),
    (
    "80.2592969, 13.1229812"
),
    (
    "80.2594669, 13.118439"
)

我的预期输出是:

(
    80.2622228, 13.125962
),
    (
    80.2617606, 13.1259684
),
    (
    80.2617484, 13.1229377
),
    (
    80.2592969, 13.1229812
),
    (
    80.2594669, 13.118439
)

从数组中删除双引号或如何将双值添加到NsmutableArray?

0 个答案:

没有答案