我正在使用準備segue在視圖控制器之間發送數據,第一個if條件在標識符爲「ShowPost」時起作用並將url發送給視圖控制器。但是當標識符是「profileInfo」時,segue不會發送數據。準備使segue不工作的多個條件
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "ShowPost" {
if let indexPath = tableView.indexPathForSelectedRow {
let _url = searchResults[indexPath.row]["link"].stringValue
let destinationController = segue.destinationViewController as! ShowPostViewController
destinationController.url = _url
}
else if segue.identifier == "ProfileInfo" {
if let indexPath = tableView.indexPathForSelectedRow {
let _userName = searchResults[indexPath.row]["owner"]["display_name"].stringValue
// print("name dc: \(destinationController.userName)")
let _userId = searchResults[indexPath.row]["owner"]["user_id"].stringValue
let _userReputation = searchResults[indexPath.row]["owner"]["reputation"].stringValue
let _ppImageString = searchResults[indexPath.row]["owner"]["profile_image"].stringValue
let destinationController = segue.destinationViewController as! ProfileInfoViewController
destinationController.userName = _userName
destinationController.userId = _userId
destinationController.userReputation = _userReputation
destinationController.ppImageString = _ppImageString
}
}
}
}
由於它的工作,但現在它是不打裏面的任何破發點:如果讓indexPath = {tableView.indexPathForSelectedRow 讓_userName = searchResults [indexPath.row] [「owner」] [「display_name」]。stringValue –
沒有得到你想說的話。你把哪個斷點打不到? – Lion
從這行代碼let _userName = searchResults [indexPath.row] [「owner」] [「display_name」]。stringValue 到if let的結尾ie ie destinationController.ppImageString = _ppImageString –