views:

1038

answers:

3

Hello users,

i have the following loop in my 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 is CLLocationCoordinate2D

but how can i use coord in the following method, because i need this to get distance between two coords:

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

}

please help me i am stranded!

thank you all for helping beforehand

+2  A: 

CLLocation has an init method named -(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude. Then use - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location to get the distance between two CLLocation objects.

AlexVogel
A: 

Oh Yes coord is an instance of koordinate i have created by self. but how can i use my instance as CLLocation???

i hope you can help me again?

Marco
+2  A: 

“how can i use my instance as CLLocation?”

You can't, because it isn't one. You need to create one.

Don't forget to release what you alloc. See the memory management rules.

Peter Hosey