I'm attempting to geocode a string into a lat/lon in the swift playground. Here is my code:
import CoreLocation
var geocoder = CLGeocoder()
geocoder.geocodeAddressString("San Francisco, CA", {(placemarks, error)->Void in
println("here")
})
However, here
never gets printed to the console (console output is blank). Why?
I was having the same issue. While there are some hints to how this is fixed in other posts, I will lay it out here so that others who find this will have something to chew on.
//: Playground - noun: a place where people can play
import UIKit
import CoreLocation
import XCPlayground
var geocoder = CLGeocoder()
var address = "Epcot Center Dr, Orlando FL"
geocoder.geocodeAddressString(address, completionHandler: {(placemarks: [AnyObject]!, error: NSError!) -> Void in
println(error)
if let placemark = placemarks?[0] as? CLPlacemark {
println(placemark.location.coordinate.latitude)
println(placemark.location.coordinate.longitude)
}
})
XCPSetExecutionShouldContinueIndefinitely()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With