Why isn't forwarding geocoding with CLGeocoder.geocodeAddressString in the playground?

I am trying to geocode a string at lat / lon in a fast playground. Here is my code:

import CoreLocation

var geocoder = CLGeocoder()
geocoder.geocodeAddressString("San Francisco, CA", {(placemarks, error)->Void in
    println("here")
})

      

However, it here

never prints to the console (the console output is empty). Why?

+3


source to share


1 answer


I had the same problem. While there are some hints as to how this is captured in other posts, I'll cover it here so others who have found it can chew on something.



//: 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()

      

+8


source







All Articles