Ich mache eine Standort-App, in der ich meinen Standort auf FireBase speichern, bekomme ich meine aktuellen Koordinaten in einer Funktion..aber wie sende ich diese Koordinaten an eine andere Funktion, die sie online speichert.Wie übergebe ich Wert von einer Funktion zu einer anderen?
Hier ist mein Code:
var latPass: Double!
var longPass: Double!
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
var location=locations[0]
let span:MKCoordinateSpan=MKCoordinateSpanMake(0.01, 0.01)
var myLocation:CLLocationCoordinate2D=CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
let region:MKCoordinateRegion=MKCoordinateRegionMake(myLocation, span)
latPass=location.coordinate.latitude
longPass=location.coordinate.longitude
}
func post(){
let lat=latPass
let long=longPass
let post : [String: Double]=["lat":lat, "long":long]
let dataBaseRef=FIRDatabase.database().reference()
dataBaseRef.child("Location").childByAutoId().setValue(post)
}
mein latPass & Langpass- sind die Koordinaten, die ich post()
Wie passieren will, kann ich es tun? Hilfe!
Ich bekomme 'nil', wenn ich' latPass' in meinem 'post()' –
@NaveenSaini drucke, überprüfen Sie das Update. Aktualisieren Sie diese Funktion. –