Reputation: 67
I am using below code - UITableViewDataSource Methods as follows:
numberOfRowsInSection
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dataArray count];
}
cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = dataArray[indexPath.row];
return cell;
}
Upvotes: 3
Views: 65
Reputation: 7474
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
But in iOS 5, to create instance of UITableViewCell we generally use this method :-
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
In iOS 5, there is no need of extra parameter which you have used in iOS 6. Just drop it and it will work (forIndexPath:).
Upvotes: 4
Reputation: 5684
Without error message is hard to say.
But I think error related to dequeueReusableCellWithIdentifier:forIndexPath:
because this method available only on iOS 6.0 and later. See more in Apple doc https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/dequeueReusableCellWithIdentifier:forIndexPath:
Upvotes: 2