Calling two different custom cell in one UITableView issue - iphone

I have created a custom cell FeatureCell which has 5 images in the row that will be called in the main view but when I call it I get empty row. So please where could be my problem?
I have googled about custom cell and I used the way that I have to use in the code below but nothing happen.
This is my FeatureCell.h
#interface FeatureCell : UITableViewCell{
IBOutlet UIImageView *img1;
IBOutlet UIImageView *img2;
}
#property (nonatomic, retain) UIImageView *img1;
#property (nonatomic, retain) UIImageView *img2;
#end
This is my FeatureCell.m
#implementation FeatureCell
#synthesize img,img1,img2,img3,img4;
#end
This is the my view-controller .m
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return [objectCollection count];
}
else{
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier1 = #"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier1 owner:nil options:nil];
cell1 = (FeatureCell*)[nib objectAtIndex:0];
}
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
if ([indexPath section] == 0) {
containerObject = [objectCollection objectAtIndex:indexPath.row];
[[cell textLabel] setText:containerObject.store];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else{
cell1.img1.image = [UIImage imageNamed:#"shower.png"];
cell1.img2.image = [UIImage imageNamed:#"parking.png"];
}
return cell;
}

You need to do something like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
containerObject = [objectCollection objectAtIndex:indexPath.row];
[[cell textLabel] setText:containerObject.store];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
static NSString* cellIdentifier1 = #"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier1 owner:nil options:nil];
cell1 = (FeatureCell*)[nib objectAtIndex:0];
}
cell1.img1.image = [UIImage imageNamed:#"shower.png"];
cell1.img2.image = [UIImage imageNamed:#"parking.png"];
return cell1;
}
}
I might have the if condition backwards so double check that.

This implementation:
#implementation FeatureCell
#synthesize img,img1,img2,img3,img4;
#end
Results in a cell with some accessor methods but no initialised instances. You need to implement an init method to create the instances or connect the variables (which you define as outlets) to the associated XIB file. Read this guide.
I also agree with the comments about the structure of how you're creating your different cell instances. It's very disorganised and you seem to be mixing up references. You should split things out into different methods or at least put the code for creating the cells inside the if statements so you can't typo the cell instance names.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) //not indexPath.section...fixed my problem
{
static NSString *CellIdentifier = #"MenuHeadingCustomCell";
MenuHeadingCustomCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell ==nil)
{
cell = [[MenuHeadingCustomCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
return cell;
}
else
{
static NSString* cellIdentifier1 = #"LevelViewCell";
LevelViewCell *cell1 =[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 ==nil)
{
cell1 = [[LevelViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier1];
// row counts which dictionary entry to load:
_Dictionary=[_array objectAtIndex:indexPath.row];
cell1.LevelTitleText.text =[NSString stringWithFormat:#"%#",[_Dictionary objectForKey:#"LevelLabelText"]];
cell1.LevelSubText.text =[NSString stringWithFormat:#"%#",[_Dictionary objectForKey:#"LevelLabelSubText"]];
cell1.LevelThumb.image =[UIImage imageNamed:[_Dictionary objectForKey:#"LevelLabelThumb"]];
}
return cell1;
}

Related

return type for CellForRowAtIndexPath

i have two tableviews in my view. i have issue in implementing the delegate methods. Can anyone help me on this. Here the problem is, this method requires a return value of type UITableViewCell right. what should i return?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView==ContactTableview)
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSString *totalString = [ContactArray objectAtIndex:indexPath.row];
NSArray *afterSeparate = [[NSArray alloc]init];
afterSeparate = [totalString componentsSeparatedByString:#"+"];
NSString *cellText = [afterSeparate objectAtIndex:0];
//NSString *detailText = [afterSeprate objectAtIndex:1];
cell.textLabel.text = cellText;
//cell.detailTextLabel.text=detailText;
return cell;
}
if (tableView==ContactTableViewLabel)
{
static NSString *CellIdentifier = #"ContactListCustomCell";
ContactListCustomCell *cell = (ContactListCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"ContactListCustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ContactListCustomCell *) currentObject;
break;
}
}
}
cell.ContactLabel.text = [LabelArray objectAtIndex:indexPath.row];
cell.ContactValue.text = [ValueArray objectAtIndex:indexPath.row];
return cell;
}
}
Use this edited code. It will also get rid you of any warning regarding return cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
static NSString *CellIdentifier_contact = #"ContactListCustomCell";
UITableViewCell *cell;
if(tableView==ContactTableview)
{
if (cell == nil) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSString *totalString = [ContactArray objectAtIndex:indexPath.row];
NSArray *afterSeparate = [[NSArray alloc]init];
afterSeparate = [totalString componentsSeparatedByString:#"+"];
NSString *cellText = [afterSeparate objectAtIndex:0];
//NSString *detailText = [afterSeprate objectAtIndex:1];
cell.textLabel.text = cellText;
//cell.detailTextLabel.text=detailText;
}
if (tableView==ContactTableViewLabel)
{
ContactListCustomCell *cell1 = (ContactListCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell1 == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"ContactListCustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell1 = (ContactListCustomCell *) currentObject;
break;
}
}
}
cell1.ContactLabel.text = [LabelArray objectAtIndex:indexPath.row];
cell1.ContactValue.text = [ValueArray objectAtIndex:indexPath.row];
cell = (UITableViewCell*) cell1;
}
return cell;
}
There is no need to cast ContactListCustomCell as a UITableViewCell. You can use ContactListCustomCell as a subclass of UITableViewCell. You can update your code like this :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if(tableView==ContactTableview)
{
static NSString *CellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
.
.
}
else if(tableView==ContactTableViewLabel)
{
static NSString *CellIdentifier = #"CustomCell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:#"yourCellNibName" owner:self options:nil];
cell = self.yourCellProperty;
self.yourCellProperty = nil;
}
.
.
}
return cell;
}
GoodLuck !!!

custom label value is disappearing when scrolling table view

I am new to iphone. my cutomcell label value is disappearing when I scroll the table view.
Again it appears when I click on that cell.
Can anyone help me?
Thanks in Advance.
//table view in view controller created in xib
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"ListOfProductsCell";
ListOfProductsCell *cell = (ListOfProductsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
NSArray *nib =[[NSBundle mainBundle] loadNibNamed:#"ListOfProductsCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
productItemDit=[productListArry objectAtIndex:indexPath.row];
NSString *offerStr= [NSString stringWithFormat:#"%.2f",[[productItemDit objectForKey:#"offer"] floatValue]];
NSString *fullCostStr=[[currencyCodeStr stringByAppendingString:#" "] stringByAppendingString:offerStr];
NSLog(#"%#",fullCostStr);
cell.itemCostLbl.text=fullCostStr;
} else {
cell.itemStepper = (UIStepper *) [cell viewWithTag:2];
cell.itemAddedLbl =(UILabel*)[cell viewWithTag:1];
}
if (tableView == self.searchDisplayProduct.searchResultsTableView) {
searchProductItemDit=[searchProductListArry objectAtIndex:indexPath.row];
NSLog(#"searchdit:%#",searchProductItemDit);
cell.itemNameLbl.text= [searchProductItemDit objectForKey:#"name"];
self.searchDisplayProduct.searchResultsTableView.separatorColor=[UIColor colorWithRed:200.0 green:0.0 blue:0.0 alpha:1.0];
} else {
productItemDit=[productListArry objectAtIndex:indexPath.row];
NSLog(#"dit:%#",productItemDit);
cell.itemNameLbl.text=[productItemDit objectForKey:#"name"];
}
cell.itemAddedLbl.text = [[NSString alloc] initWithFormat:#"%d",itemCount];
cell.itemImg.image = [UIImage imageNamed:#"profp.jpg"];
return cell;
}
Solved by doing like this
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"ListOfProductsCell";
ListOfProductsCell *cell = (ListOfProductsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
NSArray *nib =[[NSBundle mainBundle] loadNibNamed:#"ListOfProductsCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
} else {
cell.itemStepper = (UIStepper *) [cell viewWithTag:2];
cell.itemAddedLbl =(UILabel*)[cell viewWithTag:1];
}
if (tableView == self.searchDisplayProduct.searchResultsTableView) {
cell.itemNameLbl.text= [[searchProductListArry objectAtIndex:indexPath.row] objectForKey:#"name"];
} else {
cell.itemNameLbl.text=[[productListArry objectAtIndex:indexPath.row] objectForKey:#"name"];
}
cell.itemCostLbl.text=[NSString stringWithFormat:#"%# %.2f", currencyCodeStr , [[[productListArry objectAtIndex:indexPath.row] objectForKey:#"offer"] floatValue]];
cell.itemAddedLbl.text = [[NSString alloc] initWithFormat:#"%d",itemCount];
cell.itemImg.image = [UIImage imageNamed:#"profp.jpg"];
return cell;
}
As you haven't post much of the information this is my guess.when you scroll table view it internally calls the reloadData method . You need to use reuse Identifier to preserve the state of the cell. You can initialize the cell in cellForRowAtIndexPath like :
static NSString *cellIdentifier = #"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
// or cell initializing logic here for the custom cell
}
in case of custom cell add reuse identifier in the xib and use it in your cellForRowAtIndexPath method

UITableView Reuse issues

This is my cellForRowAtIndexPath code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"MonthViewPopUpCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nibObjcet = [[NSBundle mainBundle] loadNibNamed:#"MonthViewPopUpCell" owner:self options:nil];
cell = [nibObjcet objectAtIndex:0];
cellTitle.font = [UIFont fontWithName:fontB size:size4];
cellSubtitle.font = [UIFont fontWithName:fontR size:size4];
}
if (indexPath.row == 0) {
cellTitle.text = #"11:03";
}
return cell;
}
For some reason i don't understand, the tableview reuses my custom cell wrongly. I thought this code would make the first cell show 11:03 and all the rest would show me 10:00 (as in the xib file), but some other cells show 11:03 as well, and their position is changing when i scroll up and down like crazy...
Can someone show me what i've done wrong?
Thanks
It doesn't reuse the same cell in the same position, it just takes a cell that is already stored in memory and reuse it for the table in another position, so you need to set the text of it every time, for example:
if (cell == nil) {
NSArray *nibObjcet = [[NSBundle mainBundle] loadNibNamed:#"MonthViewPopUpCell" owner:self options:nil];
cell = [nibObjcet objectAtIndex:0];
cellTitle.font = [UIFont fontWithName:fontB size:size4];
cellSubtitle.font = [UIFont fontWithName:fontR size:size4];
}
if (indexPath.row == 0) {
cellTitle.text = #"11:03";
}
else{
cellTitle.text = #"10:00";
}
Usually cell gets reused once it moves out of the visible area of the UITableView. You can do one thing. Also check in nib whether your custom cell's reusable identifier is set to
MonthViewPopUpCell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"MonthViewPopUpCell"; ////As you have specified in XIB
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nibObjcet = [[NSBundle mainBundle] loadNibNamed:#"MonthViewPopUpCell" owner:self options:nil];
cell = [nibObjcet objectAtIndex:0];
cellTitle.font = [UIFont fontWithName:fontB size:size4];
cellSubtitle.font = [UIFont fontWithName:fontR size:size4];
}
if (indexPath.row == 0) {
cellTitle.text = #"11:03";
}else {
cellTitle.text = #"10:00";
}
return cell;
}
Following is the good way to call custom cell. I hope it will work.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"cell";
MonthViewPopUpCell *cell = (MonthViewPopUpCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nibObjcet = [[NSBundle mainBundle] loadNibNamed:#"MonthViewPopUpCell" owner:self options:nil];
cell = [nibObjcet objectAtIndex:0];
cellTitle.font = [UIFont fontWithName:fontB size:size4];
cellSubtitle.font = [UIFont fontWithName:fontR size:size4];
}
if (indexPath.row == 0) {
cellTitle.text = #"11:03";
}else{
cellTitle.text = #"10:00";
}
return cell;
}

My custom cell does not display

I have created a custom cell that contain a Label but when I added that in my Table View than it does not display, my view controller is not TableViewController I have seted Table View using IB and seted its delegate and datasource correctly.
I am doing this by:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
return theDataObject.myAudio.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
ExampleAppDataObject* theDataObject = [self theAppDataObject];
NSString *destinationPath = [theDataObject.myAudio objectAtIndex:indexPath.row];
NSArray *parts = [destinationPath componentsSeparatedByString:#"/"];
NSString *filename = [parts lastObject];
AudioInfoCell *cell = (AudioInfoCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[AudioInfoCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.audioName.text = filename;
return cell;
}
First check how many row set in tableView:numberOfRowsInSection method
After set the custom cell like bellow..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AudioInfoCell *cell = (AudioInfoCell *) [tableView dequeueReusableCellWithIdentifier:nil];
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"AudioInfoCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (AudioInfoCell *) currentObject;
break;
}
}
}
ExampleAppDataObject* theDataObject = [self theAppDataObject];
NSString *destinationPath = [theDataObject.myAudio objectAtIndex:indexPath.row];
NSArray *parts = [destinationPath componentsSeparatedByString:#"/"];
NSString *filename = [parts lastObject];
cell.audioName.text = filename;
return cell;
}
Two things to check:
Make sure the reuse identifier matches what is in Interface Builder
Make sure your numberOfRowsInSection and numberOfSectionsInTableView
return the right numbers
Also - I don't use:
if (cell == nil) {
cell = [[AudioInfoCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
}
for instantiating the cell. That should be taken care of in the AudioCell TableViewCell subclass you have implemented. An example of how I implement this kind of custom cell is:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"FlightPickerCell";
FlightPickerCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.tripIDLabel.text = #"Some TripID";
cell.hospitalLabel.text = #"Some Hospital";
cell.cityLabel.text = #"Some City";
return cell;
}

UITableView cell returning nil property values

I have the following:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
{
static NSString *CellID = #"FlourishCustomCell";
FlourishCustomCell *cell = (FlourishCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellID];
if (cell == nil) {
cell = [[[FlourishCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID] autorelease];
cell.frame = CGRectMake(0, 0.0, 292.0, 30);
}
id <NSFetchedResultsSectionInfo> sectionInfo =
[[appDelegate.fetchedResultsController sections] objectAtIndex:indexPath.section];
NSLog(#"DATE:%#", [sectionInfo name]); //Output: March 25
cell.dateLabel.text=[sectionInfo name];
NSLog(#"header cell:%#", cell.dateLabel.text); //Output:header cell:(null)
return cell;
}
else {
static NSString *CellIdentifier = #"IdeaCustomCell";
IdeaCustomCell *cell = (IdeaCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[IdeaCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.frame = CGRectMake(0, 0.0, 292.0, 70);
}
[self configureCell:cell atIndexPath:[self newIndexPathForIndexPath:indexPath]];
return cell;
}
}
The cells display and work fine for the else part (the IdeaCustomCell), but for some extremely frustrating reason, when I set the dateLabel of the FlourishCell, and then immediately try to access that value, I get a null value, even though I just set it! And the cell doesn't display on screen.
I tried overriding the setter method for dateLabel in the FlourishCustomCell class, and I put an NSLog statement there, but it never gets called for some reason.
I have absolutely no idea what could be causing this. I mean I'm allocating right then and there, but it's still giving me null. Any ideas?
You need to initialize the label
Solution 1: Initializing cell in code
#interface FlourishCustomCell : UITableViewCell
#property (nonatomic, retain) UILable * dateLabel;
#end
#implementation FlourishCustomCell
#synthesize dateLabel = _dateLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{
_dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,300,50)];
[self.contentView addSubview:_dateLabel]
}
return self;
}
#end
Solution 2: Initializing cell from nib
#interface FlourishCustomCell : UITableViewCell
#property (nonatomic, retain) UILable * dateLabel;
#end
#implementation FlourishCustomCell
#synthesize dateLabel = _dateLabel;
- (id)init
{
self = [[[[NSBundle mainBundle] loadNibNamed:#"YOUR_NIB_NAME" owner:nil options:nil]
lastObject]
retain];
return self;
}
#end
EDIT: oops, forgot to return self on init method, updated the answer
i had the same problem when using nibs, this worked for me
- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = #"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
NSString* nibFile = #"NibForCell";
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed: nibFile owner:nil options: nil];
cell = [topLevelObjects objectAtIndex: 0];
}
cell.cellText.text = #"test";
return cell;
}
just make sure you set the reuse identifier in the nib's properties