Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to import a custom UITableViewCell keeps giving me a file not found lexical preprocessor error in Objective-C

Trying to import a custom UITableViewCell and it keeps giving me a file not found lexical preprocessor error. I can't figure it out.

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

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

In my UItableviewcontroller.h file I've tried to import as @class and not doesnt seem to make a difference. and in my implementation file i simply

#import "ProductCell.h"

why is this? what basic step am I missing. Importing it in implementation file should solve my issue. Tried cleaning project

like image 441
Fozz Avatar asked Feb 23 '11 23:02

Fozz


2 Answers

Renaming the header file to something else and renaming it back to its original name did solve the problem for me.

like image 142
Srdr Avatar answered Nov 14 '22 11:11

Srdr


This appears to be an XCode4 bug. Despite the fact that the compiler shows an error, if you try running the project, it should work.

This is discussed in the Apple forums in the following places:

  • https://devforums.apple.com/message/369278#369278
  • https://devforums.apple.com/message/379512#379512
  • https://devforums.apple.com/message/382662#382662
like image 4
memmons Avatar answered Nov 14 '22 10:11

memmons