У меня есть (большой объем) данных, что я хочу, чтобы отправить Table View с alamofire и siftyJSONКак отправить данные в виде таблицы с Alamofire И SwiftyJSON
веб-запрос:
let postEndPoint :String = "http://jsonplaceholder.typicode.com/posts/"
код Alamofire и SwiftyJSON:
override func viewDidLoad() {
super.viewDidLoad()
Alamofire.request(.GET, postEndPoint).responseJSON { response in
// handle json
guard response.result.error == nil else{
print("error calling Get on /posts/1")
print(response.result.error)
return
}
if let value: AnyObject = response.result.value{
let post = JSON(value)
// for i in 0...post.count{
if let title = post["data"].arrayValue as? [JSON]{
self.datas = title
self.tableView.reloadData()
print("the title is :\(title)")
}else{
print("eror parsing /post/1 ")
}
// }
}
}
}
код табличное:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell")!
var dict = datas[indexPath.row]
cell.textLabel?.text = dict["userId"] as? String
cell.detailTextLabel?.text = dict["id"] as? String
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return datas.count
}
}
веб-запрос: enter link description here
Я пытаюсь опубликовать некоторые данные JSON в виде таблицы, но когда я отправить данные, которые он не возвращает ничего. Зачем??
tank you @Raj :) один вопрос, как я могу передать эти данные в виде нескольких таблиц? –
спасибо @Raj :). –