gpt4 book ai didi

iphone - NSInvalidArgumentException 原因 :-[CLLocation distanceFromLocation:]

转载 作者:行者123 更新时间:2023-11-28 22:51:16 25 4
gpt4 key购买 nike

我有这段代码可以只获取半径 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)

我的代码有什么不对?

最佳答案

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

Available in iOS 3.2 and later. Declared In CLLocation.

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

关于iphone - NSInvalidArgumentException 原因 :-[CLLocation distanceFromLocation:],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11953030/

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