如何将来自 MapKit 注释的信息发送到新的视图控制器

How to send information from MapKit annotation to a new view controller

目前我正在从 API 中提取 JSON 并将其发布到 MapKit 地图。它从 API 中提取并将其解析为 Class 市场数组,每个邮政编码的大小都不同。目前我正在尝试获取我单击的特定注释标注的信息,并在单击信息按钮时将其发送到新的视图控制器。

这是我准备 segue 的代码,当按下信息按钮时:

    //This method gets ran when the information button is pressed on the Annotation's Callout

func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView,
             calloutAccessoryControlTapped control: UIControl) {
    let market = view.annotation as! Market

    performSegue(withIdentifier: "callout", sender: market)

}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let destination = segue.destination as! CalloutViewController

    destination.market = //Yes this line isn't completed, Not sure how to get the current class from the annotation's callout when it is pressed!

    let backItem = UIBarButtonItem()
    backItem.title = "Back"
    navigationItem.backBarButtonItem = backItem
}

这是 Callout View Controller(我正在尝试获取要转到的信息。):

class CalloutViewController: UIViewController {

let market: Market! = nil

@IBOutlet weak var testView: UITextView!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.

    self.navigationController?.navigationBar.tintColor = UIColor.white
}

应该是:

destination.market = sender as? Market

还是我遗漏了什么?