object passed in delegate method becomes uninitialized in class where protocol is implemented. but same object have valid address in class from where delegate was called. This happens only in maccatalyst same code works perfectly in iOS and iPadOS
Protocol Declaration
protocol ASPatientSearchDelegate: class {
func moveToPaitentProfileScreen(patient: ASCardEntity)
}
Delegate variable declaration
weak var delegate: ASPatientSearchDelegate? = nil
Delegate calling
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let patient = self.searchResults[indexPath.row]
self.delegate?.moveToPaitentProfileScreen(patient: patient)
}
Method Implementation
extension ASAppointmentViewController: ASPatientSearchDelegate {
func moveToPaitentProfileScreen(patient: ASCardEntity) {
guard let json = patient.details as? JSON else { return }
}
}
Delegate Assigned in ASAppointmentViewController
@IBAction func searchButtonAction(_ sender: UIButton) {
let searchViewController = ASPatientSearchViewController(nibName: ASPatientSearchViewController.className, bundle: nil)
searchViewController.popoverPresentationController?.delegate = self
searchViewController.modelController.delegate = self
}
Class Used
class ASCardEntity: NSObject {
var details: Any?
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…