我有这个代码只能获得半径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)
我的代码中哪些不正确?
答案 0 :(得分:2)
方法distanceFromLocation
仅适用于iOS 3.2及更高版本。来自the documentation:
适用于iOS 3.2及更高版本。在CLLocation中声明。
我猜你的模拟器是iOS的新版本。