0
我有這樣的代碼來獲得僅10公里半徑範圍內的咖啡館:NSInvalidArgumentException原因: - [CLLocation distanceFromLocation:]
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++;
}
其上運行的iPhone模擬器,但崩潰的iPhone 2G。 (iOS 3.1.3)
什麼是不正確的在我的代碼?