<分区>
我对 swift 语言比较陌生。谁能解释一下如何像我们在 Objective-c 语言中那样在 nsmutableArray 或 nsmutableDictionary 中调用服务和存储。
<分区>
我对 swift 语言比较陌生。谁能解释一下如何像我们在 Objective-c 语言中那样在 nsmutableArray 或 nsmutableDictionary 中调用服务和存储。
最佳答案
试试这个示例代码
声明数组
var textArr = [String]()
var nameArr = [String]()
在swift3中使用alamofire
Alamofire.request(url, parameters: ["user":"any username"
,"media_id":"anyid"]).responseJSON { response in
if response.result.isSuccess == true
{
if let value = response.result.value {
let json = JSON(value)
print(self.json)
let comment_arr = self.json["comment_arr"]
for (index, _): (String, JSON) in comment_arr {
let i : Int = Int(index)!
let name = comment_arr[i]["user"].stringValue
let text = comment_arr[i]["text"].stringValue
self.nameArr.append(name)
self.textArr.append(text)
}
self.tableView.reloadData()
self.loadingNotification.hide(animated: true)
}
}
else
{
}
}
希望对你有用!!!
关于ios - 如何使用 Alamofire 快速调用 web 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39849012/