Mellon
Mellon

Reputation: 38912

Use my custom initialier to initialize my table cell (inherit UITableViewCell)

I have created my custom table cell class:

@interface CommonCell : UITableViewCell{
   ...
}

@end

In the implementation file of it, I have created a custom initializer method: initWithCellHeight:reuseIdentifier:showName

which called the [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) , like below:

@implementation CommonCell

- (id)initWithCellHeight:(float)cellHeight reuseIdentifier:(NSString *)reuseIdentifier showName:(BOOL)showName
{
    if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])) {

        [self createViews: showName];
    }
    return self;
}

When I use my cell class in my controller in the following way:

#import "CommonCell.h"

...
cell = [[[CommonCell alloc] initWithCellHeight:150 reuseIdentifier:@"CommonCellId" showName:YES] autorelease];

I got warning message : instance method "initWithCellHeight:reuseIdentifier:showName" not found

Why? Why I can not use my custom initialiser for my table cell?

Upvotes: 0

Views: 543

Answers (1)

maroux
maroux

Reputation: 3824

Why is - (id)initWithCellHeight:(float)cellHeight reuseIdentifier:(NSString *)reuseIdentifier showName:(BOOL)showName not present in the header file? You will need to declare it before using it to remove the warning.

Upvotes: 1

Related Questions