尝试导入自定义UITableViewCell不断给我一个文件找不到Objective-C中的词法预处理器错误

Foz*_*ozz 5 import objective-c

尝试导入自定义UITableViewCell,它不断给我一个文件未找到词法预处理器错误.我无法弄清楚.

ProductCell.h

#import <UIKit/UIKit.h>


@interface ProductCell : UITableViewCell {
    IBOutlet UILabel *descript;
    IBOutlet UILabel *productCode;
    IBOutlet UIImageView *prodImage;
}

@property (nonatomic, retain) IBOutlet UILabel *descript;
@property (nonatomic, retain) IBOutlet UILabel *productCode;
@property (nonatomic, retain) IBOutlet UIImageView *prodImage;

@end
Run Code Online (Sandbox Code Playgroud)

ProductCell.m

#import "ProductCell.h"


@implementation ProductCell

@synthesize descript;
@synthesize productCode;
@synthesize prodImage;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

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

@end
Run Code Online (Sandbox Code Playgroud)

在我的UItableviewcontroller.h文件中,我试图导入,@class而不是似乎没有什么区别.我简单地在我的实现文件中

#import "ProductCell.h"
Run Code Online (Sandbox Code Playgroud)

为什么是这样?我错过了什么基本步骤.在实现文件中导入它应该可以解决我的问题.试过清洁工程

小智 6

将头文件重命名为其他内容并将其重命名为其原始名称确实为我解决了问题.


mem*_*ons 4

这似乎是 XCode4 的一个错误。尽管编译器显示错误,但如果您尝试运行该项目,它应该可以工作。

Apple 论坛的以下位置对此进行了讨论: