0
我正在嘗試從Parse表中查詢數據以將其添加到prepareForSegue函數中。但是一旦進入newViewController,標籤是空白的。這是我的代碼行。查詢數據以將數據添加到prepareForSegue函數
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "marathonDetail"){
var upcoming: marathonDetailViewController = segue.destinationViewController as! marathonDetailViewController
let indexPath = self.marathonsTableView.indexPathForSelectedRow!
let currentCell = marathonsTableView.cellForRowAtIndexPath(indexPath) as! marathonTableViewCell
let marathonEvents = currentCell.marathonName.text
upcoming.nameMarathon = marathonEvents
self.marathonsTableView.deselectRowAtIndexPath(indexPath, animated: true)
var query = PFQuery(className: "marathons")
query.whereKey("marathonName", equalTo: marathonEvents!)
query.findObjectsInBackgroundWithBlock{
(marathonPickeds: [PFObject]?, error: NSError?) -> Void in
if (error == nil){
if let marathonPicked = marathonPickeds as? [PFObject]?{
for marathonPicked in marathonPickeds!{
var selectedDescription = marathonPicked.description
upcoming.marathonDescription = selectedDescription
print(selectedDescription)
}
}
}else {
print(error)
}
}
}
}
的marathonsEvents = currentCell.marathonName.text效果很好,但marathonDescription是空白。
有什麼建議嗎?我正在使用Parse作爲我的後端XCODE 7,並且迅速
我該如何刷新viewController? – Ace
請求完成後,您將設置標籤的文本。 –
好的,我必須改變代碼行var selectedDescription = wildCardPicked.description,因爲它給了我所有的信息,我把它改爲var selectedDescription = wildCardPicked.information,但現在我得到一個錯誤「PFObject的值類型沒有成員'信息'「我如何獲得信息欄中的信息? – Ace