gpt4 book ai didi

ios - didFailWithError : Error Domain=kCLErrorDomain Code=0 "The operation couldn’ t be completed.(kCLErrorDomain 错误 0。)”

转载 作者:IT王子 更新时间:2023-10-29 07:31:20 26 4
gpt4 key购买 nike

我想获取当前位置,但出现错误。

这是我的 View Controller 的一个片段。

- (void)viewDidLoad {
self.locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations {
// I would get the latest location here
// but this method never gets called
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
}

我期待委托(delegate)方法 locationManager:didUpdateLocations: 被调用,但相反,只有 locationManager:didFailWithError: 被调用,并打印如下:

didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" 

最佳答案

如果您使用的是模拟器:

  1. 在Xcode中按command + shift + ,打开方案编辑器
  2. 选择运行方案
  3. 转到“选项”标签
  4. 检查 ✅ 允许位置模拟
  5. 在下拉列表中选择一个默认位置

选择 None 作为您的默认位置可能会导致问题。

关于ios - didFailWithError : Error Domain=kCLErrorDomain Code=0 "The operation couldn’ t be completed.(kCLErrorDomain 错误 0。)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6032976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com