我正在使用Alamofire进行JSON解析。我可以从Web服务获取数据。我想设置标签。我可以使用" print()"打印任何数据。功能。但我无法设置标签。请帮帮我。
我的代码在这里。
Alamofire.request(.GET, "url").validate().responseJSON { response in
switch response.result {
case .Success:
if let value = response.result.value {
let jsonObject = JSON(value)
// this row is working.
print(jsonObject["Title"].stringValue)
// i can not print to label here
if let titleValue = jsonObject["Title"].string {
self.newsTitleLabel.text = titleValue
}
}
case .Failure(let error):
print(error)
}
}
//print result:
Bolu Dağı'nda bayram tatili yoğunluğu
//if blok:
fatal error: unexpectedly found nil while unwrapping an Optional value
答案 0 :(得分:0)
你的意思是崩溃在self.newsTitleLabel.text = titleValue
线上,对吧?
确保您的newsTitleLabel
确实存在IBOutlet / variable。