2010-07-20 42 views
0

最近下載的「MapKitDragAndDrop 3」包(http://github.com/digdog/MapKitDragAndDrop)在我的應用程序中使用。演示項目運行順利。Iphone Drag'n'Drop MapKit生成「無法識別的選擇器發送到實例」異常

DDAnnotation.h + m和DDAnnotationView.h + m文件都照原樣導入。調用該類的方法也被複制/粘貼。

DDAnnotation *annotation = [[[DDAnnotation alloc] initWithCoordinate:theCoordinate addressDictionary:nil] autorelease]; 
annotation.title = @"Drag to Move Pin"; 
annotation.subtitle = [NSString stringWithFormat:@"%f %f", annotation.coordinate.latitude, annotation.coordinate.longitude]; 

[self.mapView addAnnotation:annotation]; 

第一次運行導致「無法識別的選擇器發送到實例」異常。調試器建議我在DDAnnotation類中實現setCoordinate方法;但演示文件既沒有@synthesize也沒有方法實現。

DDAnnotation.m:

#import "DDAnnotation.h" 
@implementation DDAnnotation 

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary { 

if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary])) { 
    // NOTE: self.coordinate is now different from super.coordinate, since we re-declare this property in header, 
    // self.coordinate and super.coordinate don't share same ivar anymore. 
    self.coordinate = coordinate; // CHECKPOINT 
} 
return self; 
} 

@end 

在跟蹤它的調試器落入DDAnnotation.h檢查點的DDAnnotation.m。在我的應用程序中,它沒有。

我真的期待錯誤是愚蠢的,但我不知道在哪裏看。謝謝。

+0

我有一種感覺,當你設置字幕時,錯誤出現在行中。 這是當您嘗試訪問註釋的座標變量時。 – tadejsv 2010-07-20 17:25:20

+0

DNK,請再次獲取該項目,我已經修復了導致問題(您有)的一些項目設置錯誤。 – digdog 2010-07-22 05:43:10

回答

1

在DDAnnotation.h文件中有關於此問題的評論。

//注意:由於默認@synthesize由LLVM編譯器1.5做(與 //標誌-Xclang和-fobjc-非脆弱-ABI2),我們並不需要創建方法 // -setCoordinate :和它的ivar了。查看WWDC 2010視頻,會話 // 144 - 「高級Objective-C和垃圾收集技術」,更多詳情 //詳情。

+0

謝謝。然而我試圖做同樣的事情;結果是失敗。我想那個項目不會被更新,或者我做了錯誤的事情 - 它沒有飛過。 我剛合成了所有的變量,感覺像一個老派的古魯:-) – user962409 2010-07-20 18:09:43

0

就像皮特說,你需要在你的項目文件中更改了某些設置:

原因該項目使用LLVM中引入的綜合屬性,並且GCC編譯器不支持它。

相關問題