0

このコードでは、間違った距離を受け取ります。_latitude と _longtitude は NSString です。これを修正するための提案はありますか?

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
        locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        [locationManager startUpdatingLocation];
        CLLocation *location = [locationManager location];

        CLLocationCoordinate2D coord;
        coord.latitude = [_latitude doubleValue];
        coord.longitude = [_longitude doubleValue];

        CLLocation *anotLocation = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];
        _distancia = [NSNumber numberWithFloat:([location distanceFromLocation:anotLocation]/1000)];
4

1 に答える 1