Objective c 地图视图注释:查找坐标

Objective c 地图视图注释:查找坐标,objective-c,xcode,Objective C,Xcode,我有很多MKMapView,每个都有注释。我试图通过以下方式检索每个的坐标: for (MKMapView *map in MapViewArray) { // add textfield contents to array NSString *latitude = [NSString stringWithFormat:@"%@", map.annotations]; [latitudes addObject: latitude]; } 我在寻找正确的代码,而不

我有很多MKMapView,每个都有注释。我试图通过以下方式检索每个的坐标:

for (MKMapView *map in MapViewArray)
{
    // add textfield contents to array



    NSString *latitude = [NSString stringWithFormat:@"%@", map.annotations];

    [latitudes addObject: latitude];
}
我在寻找正确的代码,而不是以下代码:

map.annotations
我想在这里找到纬度


如何执行此操作???

每个地图注释都是一个对象,因此您必须从注释中获取坐标值。注释存储在
map.annotations
中,这是一个数组。如果每个地图只有一个注释,则可以使用:

CLLocationCoordinate2D coordinate = [[map.annotations lastObject] coordinate];
NSString *latitude = [NSString stringWithFormat:@"%.2f", coordinate.latitude];

如果有多个注释,显然必须逐个迭代每个注释,然后获取位置数据。

它给出了一个错误:在id类型的对象上找不到属性坐标