views:

64

answers:

2

Hello everybody.

Recently downloaded "MapKitDragAndDrop 3" package (http://github.com/digdog/MapKitDragAndDrop) to use in my app. The demo project runs smoothly.

Both DDAnnotation.h+m and DDAnnotationView.h+m files were imported as they are. The method of calling the class was also copied/pasted.

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];

The first run resulted in "unrecognized selector sent to instance" exception. Debugger suggests that I implement setCoordinate methods in DDAnnotation class; yet the demo files has neither @synthesize nor methods implementation.

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 

Upon tracing the DDAnnotation.m it falls into DDAnnotation.h on CHECKPOINT in debugger. In my app, it doesn't.

I really expect the mistake to be stupid, yet I just don't know where to look. Thanks.

+1  A: 

There's a comment about just this issue in the DDAnnotation.h file.

// NOTE: Since @synthesize by default is done by the LLVM 1.5 compiler (with // flag -Xclang and -fobjc-nonfragile-abi2), we don't need to create method // -setCoordinate: and its ivar anymore. Check out WWDC 2010 Videos, Session // 144 - "Advanced Objective-C and Garbage Collection Techniques", for more // details.

Pete Lyons
Thanks. Yet I've tried to do exactly the same; result was a failure. I guess that project wile wasn't updated somehow or I did something wrong - it sudt didn't fly. I just synthesized all the vars and felt like an old-school guru :-)
DNK
A: 

Just like pete said, you need to change some settings in your project file:

Cause the project is using synthesized property that introduced in LLVM, and the GCC compiler does not support it.

digdog