2016-09-14 1 views
0

나는이 오류가 무엇입니까 :위치를 업데이트하는 중 오류가 발생했습니다. 작업을 완료 할 수 없습니다. (kCLErrorDomain 오류 0)

Error while updating location The operation couldn’t be completed. (kCLErrorDomain error 0.)

내 문제는이 오류가 거의 모든 시간을 내가 시뮬레이터를 실행 보여주고 있다는 것입니다 그것은 그 오류를 나에게 모든 시간을 보여주는 유지하는 시뮬레이터 실행 (매 시간이 내가 viewController지도와 함께이 오류를 보여줍니다. 이상한 것은 때로는이 오류가 nil이며 모든 것이 잘된다는 것입니다. 실제 장치에서는 잘 작동하지만 위치 (시뮬레이터에서)로 뭔가를 시험해보고 싶을 때면 시뮬레이터를 작동시킬 때까지 약 7 번 다시 시작해야합니다.

이의 Info.plist입니다 :

func locationManager(manager: CLLocationManager, didFailWithError error: NSError) { 
     print("Error while updating location " + error.localizedDescription) 

     let alertController = UIAlertController(title: "Sorry!", message: "We were unable to find your location", preferredStyle: UIAlertControllerStyle.Alert) 
     let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil) 
     alertController.addAction(defaultAction) 

     presentViewController(alertController, animated: true, completion: nil) 
     print("Error...") 
    } 

내 질문은 왜이다 : 이것은 내 코드

enter image description here

입니다 :

enter image description here

내 위치는 정의입니다 때때로 만 작동합니까? 고맙습니다.

+0

이 링크를 확인할 수 있습니다. http://stackoverflow.com/questions/6032976/didfailwitherror-error-domain-kclerrordomain-code-0-operation-couldn-t-be –

+0

나는 이미 그 질문을 보았고 해결책을 찾지 못했습니다./ –

+1

그런 다음 시뮬레이터 메뉴> 디버그> 위치> 사용자 정의를 선택하거나 0r를 선택하십시오. 인터넷 연결을 확인하십시오. – Sandy

답변

1

제발,이 사실을 알려주세요. 시뮬레이터에서 실행 한 다음 시도하십시오. enter image description here

업데이트 : 내가 NONE로 위치를 할당 할 때

난 그냥 시도

, 그것은 작동하고 잘 같은 오류가 제공됩니다. 작업 코드

import CoreLocation 
Conform CLLocationManagerDelegate 
Create var locationManager:CLLocationManager! 
Plist - NSLocationAlwaysUsageDescription add. 

override func viewDidLoad() { 
    super.viewDidLoad() 
    locationManager = CLLocationManager() 
    locationManager.delegate = self 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest 
    locationManager.requestAlwaysAuthorization() 
    locationManager.startUpdatingLocation() 
} 

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    print("locations = \(locations)") 
} 

func locationManager(manager: CLLocationManager, didFailWithError error: NSError) { 
    print("Error while updating location " + error.localizedDescription) 

    let alertController = UIAlertController(title: "Sorry!", message: "We were unable to find your location", preferredStyle: UIAlertControllerStyle.Alert) 
    let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil) 
    alertController.addAction(defaultAction) 

    presentViewController(alertController, animated: true, completion: nil) 
    print("Error...") 
} 

내가 무엇입니까 위치가 제대로 위의 코드를 사용하고 내가 시뮬레이터 다음지고 다음과 같은 오류의 위치를 ​​넣어하지 않은 경우 :

오류 위치를 업데이트하는 동안 작업을 완료 할 수 없습니다. (kCLErrorDomain 오차 0)

올바르게 실행 : 위치 = < + 37.33233141, -122.03121860> +/- 5.00m (MPS 속도 0.00/코스 -1.00) 9/14/16 2 @ : 34 : 46 PM Pakistan Standard Time]

+0

그건 문제가 아니야 ... :/맞았 어 –

+0

내 xcode를 xcode8로 업데이트했는데 오류가 사라졌습니다. –

관련 문제