ios - Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)" -
import uikit import corelocation class viewcontroller: uiviewcontroller, cllocationmanagerdelegate { @iboutlet var latlabel: uilabel! @iboutlet var longlabel: uilabel! @iboutlet var courselabel: uilabel! @iboutlet var speedlabel: uilabel! @iboutlet var altlabel: uilabel! @iboutlet var addresslabel: uilabel! var manager:cllocationmanager! var userlocation:cllocation = cllocation() override func viewdidload() { super.viewdidload() manager = cllocationmanager() manager.delegate = self manager.desiredaccuracy = kcllocationaccuracybest manager.requestwheninuseauthorization() manager.distancefilter = 50 manager.startupdatinglocation() } func locationmanager(manager: cllocationmanager!, didupdatelocations locations: [anyobject]!) { userlocation = locations[0] cllocation println(userlocation.coordinate.latitude) var latitude:cllocationdegrees = userlocation.coordinate.latitude latlabel.text = "\(latitude)" var longitude:cllocationdegrees = userlocation.coordinate.longitude longlabel.text = "\(longitude)" var course:cllocationdirection = userlocation.course courselabel.text = "\(course)" var speed:cllocationspeed = userlocation.speed speedlabel.text = "\(speed)" var altitude:cllocationaccuracy = userlocation.altitude altlabel.text = "\(altitude)" clgeocoder().reversegeocodelocation(userlocation, completionhandler: { (placemarks, error) -> void in if (error != nil) { println(error) } else { if let p = clplacemark(placemark: placemarks?[0] clplacemark) { println(p) } } }) //println("location = \(locations)") println(locations) } }
i keep getting error error domain=kclerrordomain code=2 "the operation couldn’t completed. (kclerrordomain error 2.)" when try users closest address. not sure issue is, can see going on? thanks.
that's network error, clgeocoder needs working network connection in order reverse geocode location, according the docs.
also, clgeocoder throttle geocoding requests, returning same error if exceed request rate, documented in class reference.
Comments
Post a Comment