我正在尝试为 iPhone Mapkit 应用程序创建 MKAnnotationView 的子类,但由于某种原因,我突然遇到了这个错误:
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
这些是我似乎导致错误的代码的头文件和主文件。尽管此文件没有特别显示该错误,但如果我将 .m 文件从 @implementation 注释到 @end,则不会出现该错误。但是,如果我评论实现中的所有内容(不包括 @implementation 本身),它仍然会出现。
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
这基本上与 Xcode 通过New File... > Objective-C Class > Subclass of: UIView
更改子类创建的代码相同。
我在运行 Xcode 3.2.1 版的 Snow Leopard 上。