Hi, I have a cell with 2 buttons. Both buttons need to pass the same array but to 2 different view controllers depending on the user’s selection. The problem I’m having is that I cannot pass the array to one of the VCs, I get this error: “Expression type '()' is ambiguous without more context”. Any help is greatly appreciated. Here is my code:
Inside the TableViewCell
protocol PatientDataCellDelegate {
func patCommentBtnTapped (ptData: PTData)
func dischargeBtnTapped (ptData: PTData)
}
@IBAction func addCommentBtnTapped(_ sender: UIButton) { //Button to segue to the Comments VC
delegate?.patCommentBtnTapped(ptData: ptData)
}
@IBAction func patientDischargeBtnTapped(_ sender: UIButton) { //Button to segue to the Discharge VC
delegate?.dischargeBtnTapped(ptData: ptData)
}
View Controller
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "goToComments" {
if let commtsVC = segue.destination as? CommentsVC {
if let ptDatas = sender as? PTData {
commtsVC.ptDatas = ptDatas
}
}
} else if segue.identifier == "goToDischarge" {
if let discharVC = segue.destination as? DischargeVC {
if let ptDataFromCell = sender as? PTData {
discharVC.patDischargeFromCell = ptDataFromCell
}
}
}
}
}
extension PatdataVC: PatientDataCellDelegate {
func patCommentBtnTapped (ptData: PTData) { //Segue to Comments VC
performSegue(withIdentifier: "goToComments", sender: ptData)
}
func dischargeBtnTapped(ptData: PTData) {. // Segue to Discharge VC
performSegue(withIdentifier: "goToDischarge", sender: ptData)
}
}
DischargeVC
var patDischargeFromCell = [DischargePatient]()