我的数据,我想送表视图与alamofire一个(大量)和siftyJSON如何将数据发送到表视图与Alamofire而SwiftyJSON
Web请求:
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
}
}
Web请求:enter link description here
我想一些JSON数据发布到表视图,但是当我发送数据它没有返回。为什么??
坦克你@Raj :) 一个问题我该如何将这些数据传递给多表视图? –
谢谢@Raj :)。 –