CLLocationCoordinate2D к CLLocation

у меня есть следующий цикл в моем viewDidLoad:

    for(int i=1; i<[eventsArray count]; i++) {
  NSArray *componentsArray = [[eventsArray objectAtIndex:i] componentsSeparatedByString:@","];
  if([componentsArray count] >=6) {
   Koordinate *coord = [[Koordinate alloc] init];
   coord.latitude = [[componentsArray objectAtIndex:0] floatValue];
   coord.longtitude = [[componentsArray objectAtIndex:1] floatValue];
   coord.magnitude = [[componentsArray objectAtIndex:2] floatValue];
   coord.depth = [[componentsArray objectAtIndex:3] floatValue];
   coord.title = [componentsArray objectAtIndex:4];
   coord.strasse = [componentsArray objectAtIndex:5];
   coord.herkunft = [componentsArray objectAtIndex:6];
   coord.telefon = [componentsArray objectAtIndex:7];
   coord.internet = [componentsArray objectAtIndex:8];
   [eventPoints addObject:coord];


  }

coord является CLLocationCoordinate2D

но как может я использовать coord в следующем методе, потому что мне нужно это для получения расстояния между двумя проводами:

    - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{

}

помогите мне, я скручиваюсь!

спасибо всем за помощь заранее

24
задан Abizern 23 February 2010 в 14:40
поделиться

2 ответа

CLLocation имеет метод init с именем -(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude. Затем используйте - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location для получения расстояния между двумя объектами CLLocation.

40
ответ дан 28 November 2019 в 22:44
поделиться

"Как я могу использовать мой экземпляр как CLLocation?"

Вы не можете, потому что он не является таковым. Вам нужно создать его.

Не забудьте освободить то, что вы выделили. Смотрите правила управления памятью.

2
ответ дан 28 November 2019 в 22:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: