title: Ios how to pass google map userData to next view
body: <p>I'm trying to pass google map's <code>userData</code> to next view when user tapped custom info window. </p>
  
  <p>first I created model object like so.</p>
  
  <pre><code>import UIKit
  import Firebase
  
      struct Team {
  
          var key: String
          var teamName: String
          var league: String
          var lat: Double
          var lng: Double
  
          init(snapshot: DataSnapshot) {
  
              self.key = snapshot.key
              self.teamName = (snapshot.value as! NSDictionary)["teamName"] as? String
              self.league = (snapshot.value as! NSDictionary)["league"] as? String ?? ""
              self.lat = (snapshot.value as! NSDictionary)["lat"] as? Double ?? 0
              self.lng = (snapshot.value as! NSDictionary)["lng"] as? Double ?? 0
          }
      }
  </code></pre>
  
  <p>I fetched database and put <code>userData</code> like so </p>
  
  <pre><code>var teams = [Team?]()
  
      func fetchTeams(){
  
              let teamRef = Database.database().reference().child("teams")
              teamRef.observe(.value, with: { (snapshot) in
                  var result = [Team]()
  
                  for child in snapshot.children {
                      let child = Team(snapshot: child as! DataSnapshot)
                      result.append(child)
                      self.teams = result
                  }
  
                  for team in self.teams {
                      guard let lat = team?.lat else { return }
                      guard let lng = team?.lng else { return }
                      let marker: GMSMarker = GMSMarker()
                      marker.position = CLLocationCoordinate2DMake(lat, lng)
                      marker.map = self.mapView
                      marker.userData = team
                  }
  
              }, withCancel: nil)
          }
  </code></pre>
  
  <p>this <code>func</code> works perfectly so I guess <code>userData</code> has its property correctly.</p>
  
  <pre><code>func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -&gt; UIView? {
              let infoWindow = Bundle.main.loadNibNamed("Marker", owner: self, options: nil)?.first as! MarkerView
  
              infoWindow.teamLabel.text = (marker.userData as! Team).teamName
  
              return infoWindow
          }
  
  
  func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
          self.performSegue(withIdentifier: cellId, sender: self)
      }
  
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          if segue.identifier == cellId {
              let next: NextViewController = segue.destination as! NextViewController
              let marker = GMSMarker()
              next.team = marker.userData as? Team
          }
      }
  </code></pre>
  
  <p>I implemented like above to pass data to <code>NextViewController</code>.
  it worked fine till <code>performSegue</code> but <code>next.team</code> is nil. Does anyone know why? 
  Thank you in advance!</p>