2011-09-20 107 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發佈之前。