2

so I figured out how to make it so that when i tap a google maps marker info window it takes me to a different view controller but now I also want to pass the currently tapped on markers snippet and title value to that next view controller. I am using the google maps api and programming in swift. The following is the code that I am currently using:

func mapView(mapiew: GMSMapView, didTapInfoWindowOfMarker marker: GMSMarker) {
    let next = self.storyboard?.instantiateViewControllerWithIdentifier("ViewUserProfile") as! ViewUserProfile
    self.navigationController?.pushViewController(next, animated: true)
}

That pushes to a new view controller, I just need to figure out now how to pass the snippet and title value through that function so that I can use it in the next view controller.

Any help will be much appreciated!!!

Rohan Vasishth
  • 169
  • 1
  • 13

1 Answers1

0

In order to transfer data. You must create a new file with a struct:

struct YourVariables {

static var variable = ""

}

You can then go in whatever view controller you want to set the variable like this : YourVariables.variable = "newVariableData"

You then simply go in whatever view controller you want to access the data and set a label.text = YourVariables.variable

Rohan Vasishth
  • 169
  • 1
  • 13