D
D
Daniil Chepenko2015-10-29 13:25:33
iOS
Daniil Chepenko, 2015-10-29 13:25:33

How to display my geoposition in textfield?

Good afternoon!
I'm making an educational geolocation app!
I want to transfer my geolocation to the text field by the button. I
wrote a function that takes the location and returns the addresses. Here I also want to transfer value of the address.

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

    print (locations)
    let UserLocation:CLLocation = locations[0]

    CLGeocoder().reverseGeocodeLocation(UserLocation) { (placemarks, error) -> Void in

        if error != nil {
            print(error)
        } else {
            let p = placemarks?.first

            print p


        }

    }


}

How can I call this function in
@IBAction func MyLocationBtn(sender: AnyObject) {
        
       
    }

Or do you have to re-write everything in the button?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question