Iphone MKMapView视图用于注释,保存注释

Iphone MKMapView视图用于注释,保存注释,iphone,mkmapview,Iphone,Mkmapview,根据我的理解,当你做类似的事情时: [self.mapView addAnnotation:anAddress]; 它向地图添加注释,然后查看视图的委托方法,如下所示: - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString *placeMarkIdentifier = @"SimplePinI

根据我的理解,当你做类似的事情时:

[self.mapView addAnnotation:anAddress];
它向地图添加注释,然后查看视图的委托方法,如下所示:

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation {
    static NSString *placeMarkIdentifier = @"SimplePinIdentifier";
    if ([annotation isKindOfClass:[AddressAnnotation class]]) {
        MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:placeMarkIdentifier];
        if (annotationView == nil) {
            annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:placeMarkIdentifier];
        }
        else {
            annotationView.annotation = annotation;
        }
        NSLog(@"my annotation: %@", [annotation description]);
        annotationView.enabled = YES;
        annotationView.animatesDrop = YES;
        annotationView.draggable = YES;
        annotationView.canShowCallout = YES;
        annotationView.tag = ANNOTATION_VIEW_TAG;

        UIButton *detailDisclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        annotationView.rightCalloutAccessoryView = detailDisclosureButton;

        [self performSelector:@selector(showCallout:) withObject:annotation afterDelay:0.5];

        return annotationView;
    }
    return nil;
}

请提供保存位置的代码并创建另一个注释。我想这两个物体可能是一样的。您是否记录了这两个对象以检查其是否相同?我在保存位置的位置添加了代码。我相信这两个对象是不同的,因为当我在保存位置后记录输出时,内存地址是不同的。我看不到您添加的代码。顺便说一句,位置坐标不同,对吗?很抱歉,我还没有单击“保存编辑”。我想我做到了:是的,我记录了位置坐标,事实上它是不同的。
[self.mapView addAnnotations:_locations]; // where _locations is an array that stores my saved <MKAnnotation> objects
- (void)mapPickerDidSelectMap:(Map *)aMap {
    DataManager *dmgr = [DataManager sharedInstance];
    if (![dmgr locationExists:self.address forMap:aMap]) {
        NSMutableArray *oldLocations = [[NSMutableArray alloc] initWithArray:aMap.locations];
        [oldLocations addObject:self.address];
        aMap.locations = oldLocations;        
    }
    NSLog(@"%s", __FUNCTION__);
    [dmgr.maps enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        NSLog(@"obj: %@", [obj description]);
    }];
}