0
我想從JSON請求控制檯輸出並將其作爲用戶的文本標籤發佈。我似乎無法得到它的工作。有什麼建議?謝謝!它打印在控制檯罰款,但不會針對「self.resultLabel.text = JSON」Swift控制檯輸出到文本標籤
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options:.AllowFragments)
print(json)
dispatch_async(dispatch_get_main_queue(),{
self.myActivityIndicator.stopAnimating()
self.myImageView.image = nil;
self.resultLabel.text = json
func loadSites(){
//trying to get the post to show up in the place of the invisible label
}
});
}catch {
print(error)
}
label.text需要一個字符串和JSON是不完全的字符串。你有沒有嘗試json.description? – alexburtnik
非常感謝您的回覆Alex。它看起來像這樣修復了這個錯誤:self.resultLabel.text =(作爲AnyObject的json).description – Justin