【发布时间】:2015-03-10 23:59:34
【问题描述】:
我的 Swift 代码有问题,其中包括框架 Alamofire 和 SwiftyJson。
我正在尝试通过 https://gdata.youtube.com/feeds/api/videos?q=kortsagt&max-re%E2%80%8C%E2%80%8Bsults=5&v=2&alt=jsonc&orderby=published 从 YouTube API 获取一些数据
并且代码运行良好,直到到达与
if let data = jsonObj.arrayValue as [JSON]?{}
然后就死在那里。
这是我的示例代码:
func loadNewVideo(){
if(loadingStatus == false){
loadingStatus == true
dataVideo.removeAll()
Alamofire.request(.GET, "https://gdata.youtube.com/feeds/api/videos?q=kortsagt&max-re%E2%80%8C%E2%80%8Bsults=5&v=2&alt=jsonc&orderby=published").responseJSON { (request, response, json, error) in
//println(json)
if json != nil {
var jsonObj = JSON(json!)
println(jsonObj)
if let data = jsonObj.arrayValue as [JSON]? {
println(data)
dataVideo = data
self.collectionView?.reloadData()
}
else {
println("loading error")
}
}
}
}
else{
println("Loader JSON")
}
}
这段代码有什么问题,我该如何解决?
【问题讨论】:
标签: api swift youtube alamofire