theShay
theShay

Reputation: 247

NSInvalidArgumentException reason:-[CLLocation distanceFromLocation:]

I have this code to get only cafes that are within a radius of 10 km :

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++;
}

it runs on the iOS Simulator but Crashes on iPhone 2G. (iOS 3.1.3)

what is not right in my code?

Upvotes: 0

Views: 188

Answers (1)

Dustin
Dustin

Reputation: 6803

The method distanceFromLocation is only available in iOS 3.2 and later. From the documentation:

Available in iOS 3.2 and later. Declared In CLLocation.

I'm guessing your simulator is a newer version of iOS.

Upvotes: 2

Related Questions