我正在尝试调用MKPolylines的+ polylineWithCoordinates:count:方法。
在这种情况下,如何创建CLLocationCoordinate2D *对象。我已经在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);在上面的例子中,数组mutablePoints中是什么类型的条目?
发布于 2013-06-26 16:37:09
如果您的问题仅仅是数组中是哪种类型的条目,那么答案非常简单:NSValue条目。您可以查看此guide以了解有关如何使用NSValues的更多信息。
发布于 2013-06-26 16:42:19
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;
}https://stackoverflow.com/questions/17315098
复制相似问题