【问题标题】:NSInvalidArgumentException reason:-[CLLocation distanceFromLocation:]NSInvalidArgumentException 原因:-[CLLocation distanceFromLocation:]
【发布时间】:2012-08-14 13:11:59
【问题描述】:

我有这个代码只能获取半径 10 公里内的咖啡馆:

for (NSString *ndlog in log) {
    NSString *name = [names objectAtIndex:i];
    NSString *city = [citys objectAtIndex:i];
    NSString *chain = [chains objectAtIndex:i];
    NSString *street = [streets objectAtIndex:i];
    NSString *ndlig = [lig objectAtIndex:i];
    dlog = [ndlog doubleValue];
    dlig = [ndlig doubleValue];
    NSLog(@"%@,%@,%@,%@,%f,%f,%@,%@", name, city, chain, street, dlog, dlig, ndlog, ndlig);
    CLLocation *location = [[CLLocation alloc] initWithLatitude:dlog longitude:dlig];
    double meters = [userLocation distanceFromLocation:location];
    if (meters < 10000) {
        NSString *data = [NSString stringWithFormat:@"%@,%@,%@,%@", name, city, chain, street];
        [tableData addObject:data];
    }
    i++;
}

它在 iOS 模拟器上运行,但在 iPhone 2G 上崩溃。 (iOS 3.1.3)

我的代码中有什么不正确的地方?

【问题讨论】:

    标签: iphone objective-c ios ios-3.x


    【解决方案1】:

    distanceFromLocation 方法仅适用于 iOS 3.2 及更高版本。来自the documentation

    适用于 iOS 3.2 及更高版本。在 CLLocation 中声明。

    我猜你的模拟器是更新版本的 iOS。

    【讨论】:

      猜你喜欢
      • 2011-07-09
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多