Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 错误域=kCLErrorDomain代码=2“;操作无法’;不可能完成。(kCLErrorDomain错误2)。”;_Ios_Swift - Fatal编程技术网

Ios 错误域=kCLErrorDomain代码=2“;操作无法’;不可能完成。(kCLErrorDomain错误2)。”;

Ios 错误域=kCLErrorDomain代码=2“;操作无法’;不可能完成。(kCLErrorDomain错误2)。”;,ios,swift,Ios,Swift,当我试图获取用户最近的地址时,我不断收到此错误,错误为Domain=kclerordomain Code=2“操作无法完成。(kclerordomain错误2.)”。我不知道问题是什么,有人能看到发生了什么吗?谢谢。这是一个网络错误,据介绍,CLGeocoder需要一个工作的网络连接才能对位置进行反向地理编码 此外,CLGeocoder将限制地理编码请求,如果超过请求速率,则返回相同的错误,这也记录在类参考中。或者,您可以将lat long传递给此,并根据json中的“类型”获取与地址相关的所有

当我试图获取用户最近的地址时,我不断收到此错误,错误为Domain=kclerordomain Code=2“操作无法完成。(kclerordomain错误2.)”。我不知道问题是什么,有人能看到发生了什么吗?谢谢。

这是一个网络错误,据介绍,CLGeocoder需要一个工作的网络连接才能对位置进行反向地理编码


此外,CLGeocoder将限制地理编码请求,如果超过请求速率,则返回相同的错误,这也记录在类参考中。

或者,您可以将lat long传递给此,并根据json中的“类型”获取与地址相关的所有字段,如所述“网络不可用或出现网络错误。”可能很傻,但您是否检查了网络连接?为了完整性,请选择“最大速率”“文件中提到的未指定。虽然苹果建议每个应用每分钟进行一次地理编码,但我还是设法一个接一个地进行了大约100次地理编码…@saso:当然,但100不是一个保证的比率。如果服务器有太多的请求,它将限制您的响应。我在滥用服务时不止一次看到过这种情况。
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] as 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] as CLPlacemark) {
                    println(p)
                }
            }

        })



        //println("Location = \(locations)")
        println(locations)
    }


}