A: 

print value of

[self.ItemArray objectAtIndex:indexPath.row]; 

in NSLog... check wether it prints valid value or not....It seems that array's object releasing somewhere before it..

mihirpmehta
also print the value of [self.ItemArray count] within (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Till
+1  A: 

During the -(id)initWithFrame:(CGRect)frm method your code calls -reloadData on the UITableView. At this point in time your ItemArray is not available.

Therefore, when UITableView calls it's delegates -numberOfSectionsInTableView: and -tableView:numberOfRowsInSection: methods to get information on what to display in the view, they return one section with zero rows.

Nothing displayed!

It might be a (one) solution to change your initialization of the ItemArray:

-(NSMutableArray *) displayItemArray {
    if(ItemArray==nil) { 
        ItemArray=[[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
        [self reloadData];
    }
    return ItemArray;
}
Ralf Edmund
+1  A: 

You did never initialize the ItemArray within your code snippet. Remove the displayItemData method and change the initializer towards:


-(id)initWithFrame:(CGRect)frm 
{
    if ((self = [super initWithFrame:frm])) != nil)
    {
        self.delegate=self;
        self.dataSource=self;
        ItemArray=[[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
        [self reloadData];
    }
    return self;
}

You could also simply call that displayItemArray method within the initializer. I feel that method makes no sense as it stands and hence my recommendation to remove it altogether.

Without trying it myself, I am still pretty confident that you can also get rid of that [self reloadData] within the initializer.

Till