2011-09-20 104 views
0

我有一个AddressAnnotation类符合MKAnnotation类。我使用MKReverseGeocoderDelegate方法从用户位置获取地址。在那个代表中,我放下了这个针。我将该引脚设置为可拖动,并且在调用以下方法时,我再次启动反向地址解析器。拖动MKPinAnnotationView抛出错误

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { 
    if (newState == MKAnnotationViewDragStateEnding) { 
     CLLocationCoordinate2D newCoordinate = view.annotation.coordinate; 
     MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newCoordinate]; 
     reverseGeocoder.delegate = self; 
     [reverseGeocoder start]; 
    } 
} 

它适用于约3引脚拖动,直到我得到以下错误。我不确定它是什么意思或发生了什么。任何帮助,将不胜感激。谢谢! “

”类AddressAnnotation的实例0x1b7ac0被释放,而键值观察者仍然注册它,观察信息被泄漏,甚至可能被错误地附加到某个其他对象上,在NSKVODeallocateBreak上设置一个断点以停止在调试器中。这是当前的观察信息:“

回答

0

听起来好像你创建了一个名为AddressAnnotation的MKAnnotation子类。一个类正在使用键值观察来观察这个类的属性的成员,并且AddressAnnotation的实例在不移除观察者的情况下被解除分配。我认为你可以通过运行

- (void)removeObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath 

AddressAnnotation发布之前。