我在someKey
键下的nsuserdefaults中存储了一个字符串数组。
我正在构建Alamofire
查询:
var params = [
"long": lon,
"lat": lat,
"startDate": DateCalc.convertValueToDate(defaults.floatForKey("startDate"))
] as [String: AnyObject]
Alamofire.request(.GET, "\(serverURL)/tests", parameters: (params))
.validate()
.responseJSON { response in
现在,基于某些条件,我想在我的params
数组中追加先前设置的String数组。
我尝试这样做:
params["someKey"] = defaults.objectForKey("someKey")
然后输入参数如下:
params: ["long": 19.09421499999999, "someKey": <__NSCFArray 0x7f8322713990>(
一个, 二, 三 ) ,“lat”:51.90671500000001,“startDate”:2011-09-28T00:00:00.000Z]
我该如何更改它以便我可以传递字符串数组,例如:
params: ["long": 19.09421499999999, "someKey": "one, two three", "lat": 51.90671500000001,"startDate": 2011-09-28T00:00:00.000Z]
答案 0 :(得分:3)
let joinedString = ["one", "two", "three", "four", "five"].joinWithSeparator(", ")
print(joinedString)