0

I am trying to to call MKPolylines' + polylineWithCoordinates:count: method.

How can I create a CLLocationCoordinate2D * object in this case. I have gone through this particular answer in CLLocationCoordinate2D without knowing how many will be in the array?

// unpacking an array of NSValues into memory
CLLocationCoordinate2D *points = malloc([mutablePoints count] * sizeof(CLLocationCoordinate2D));
for(int i = 0; i < [mutablePoints count]; i++) {
[[mutablePoints objectAtIndex:i] getValue:(points + i)];
}

MKPolyline *myPolyline = [MKPolyline polylineWithCoordinates:points count:[mutablePoints count]];
free(points);

What kind of entries are in the array mutablePoints in the above case?

Community
  • 1
  • 1
Xavi Valero
  • 2,047
  • 7
  • 42
  • 80

2 Answers2

0

If your question is simply what kind of entries are in the array, the answer is quite simple: NSValue entries. You can have a look at this guide for more info on how to use NSValues.

micantox
  • 5,446
  • 2
  • 23
  • 27
0
CLLocationCoordinate2D coordinate;
    for (int i = 0; i < arr.count; i++)
    {
        float t1 = [[arr objectAtIndex:1] floatValue];
        float t2 = [[arr objectAtIndex:0] floatValue];

        coordinate.latitude = t1;
        coordinate.longitude = t2;

    }
Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42