开发者

What's causing this error in a subclass of MKAnnotationView?

I'm trying to create a subclass of MKAnnotationView for an iPhone Mapkit app, but for some reason I am suddenly encountering this error:

Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

These are my header and main files for the code that seems to be causing the error. Though the error does not show up for this file specifically, it does not appear if I comment out the .m file from @implementation to @end. It does still appear if I comment everything in the implementation not including the @implementation itself, however.

PhotoAnnotationView.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface PhotoAnnotationView : MKAnnotationView { 
    UIImageView *thumb; 
}

@property (nonatomic, retain) IBOutlet UIImageView *thumb;

@end

PhotoAnnotationView.m

#impo开发者_如何转开发rt "PhotoAnnotationView.h"


@implementation PhotoAnnotationView

@synthesize thumb;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}


@end

This is basically the same code that Xcode created via New File... > Objective-C Class > Subclass of: UIView with the subclass changed.

I'm on Snow Leopard running version 3.2.1 of Xcode.


Do you link your application with MapKit.framework? The compiler may not know about MKAnnotationView cs and therefore output this error.

To add the framework to your project go to Target settings in one of the menus of Xcode (I don't have Xcode here at hand, unfortunately) and on the first tab click the plus button and select MapKit.framework from the list.

I hope that'll help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜