samedi 1 avril 2017

How to check if segue completed Swift 3?

I have a segue which passes location data from a table view. I need to add a map annotation after this segue has completed, but the map is my initial VC, so it crashes on load due to the lack of data as the segue has not occurred.

I think I need to wrap the following code (in the viewDidLoad) in an if statement that checks if the segue has occurred, or check if there is any data available to use.

    let roomPin = MGLPointAnnotation()
    roomPin.coordinate = CLLocationCoordinate2D(latitude: room.latitude, longitude: room.longitude)

    mapView.addAnnotation(roomPin)

Not entirely sure how I should be checking if there is any data to use.

Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire