NSInvalidArgumentException причина:-[CLLocation distanceFromLocation:]
У меня есть этот код, чтобы получить только кафе, которые находятся в радиусе 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 Simulator, но вылетает на iPhone 2G. (iOS 3.1.3)
что не так в моем коде?
1 ответ
Метод distanceFromLocation
доступно только в iOS 3.2 и более поздних версиях. Из документации:
Доступный в iOS 3.2 и позже. Объявлено в CLLocation.
Я предполагаю, что ваш симулятор - более новая версия iOS.