【发布时间】:2017-08-18 06:46:27
【问题描述】:
我在 Swift 中创建了一个数组。我有一个 node.js API,在这个 API 中只传递这样的字符串类型数据
let Dic = "{\"type\": \"0\",\"message\": \"\(message)\", \"sender_id\":\"\(username)\", \"reciever_id\": \"61\", \"\(username)\": \"2017-05-09 03:02:55 PM\"}"
我无法在 API 中传递这个 Dic。但问题是,我有一个数组,如何将数组转换为字符串。我必须在 Dic 中再添加一个参数,然后传递这个数组 这是我的代码如何生成这个数组
(
{
Desc = "This is suger for m23 type ";
Price = 50;
Product = "Suger temp";
},
{
Desc = "This is suger for m23 type ";
Price = 50;
Product = "Suger temp";
}
)
代码是
let ary_allPRoduct :NSMutableArray = []
for i in 0..<count {
var dict = Dictionary<String, Any>()
dict["Product"]="Suger temp"
dict["Desc"]="This is suger for m23 type "
dict["Price"]="50"
ary_allPRoduct.add(dict)
}
print(ary_allPRoduct)
【问题讨论】:
标签: arrays string swift3 parameter-passing