English 中文(简体)
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

#import "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.





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签