3
嗨我有一個解析問題。alamofireobjectmapper requestObject無法進行正確的請求和映射
當我嘗試在我的tableviewcell 中解析this JSON並且無法獲取我需要的值。
我的要求:
let videos = NewestVideos()
let URL = "https://api.vid.me/channel/1/new"
override func viewDidLoad() {
super.viewDidLoad()
Alamofire.request(.GET, self.URL).responseObject { (response: Response<NewestVideos, NSError>) in
switch response.result {
case .Success(self.videos):
print("")
case .Failure(let error):
print("Request failed with error: \(error)")
}
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! NewTableViewCell
cell.newVideoNameLabel.text = resultr
return cell
}
我如何在tableviewcell值,並進行正確的請求?
我通過ObjectMapper映射:
class Videos: Mappable {
var embedUrl: String?
var title: String?
required init?(_ map: Map){
}
func mapping(map: Map) {
embedUrl <- map["embed_url"]
title <- map["title"]
}
}
class NewestVideos: Mappable {
var videos: [Videos]? = []
required init?(_ map: Map){
}
func mapping(map: Map) {
videos <- map["videos"]
}
}
哦thnkü它必須工作,但我有一個問題在這裏我必須做出reloadData()查看變化 – DmitrievichR
我更新了我的答案 – Callam
我天璣undetstand我的應用程序崩潰,我認爲tabbarcontroller與tableviewcontroller? – DmitrievichR