Reputation: 3
how to display a number from 1 to array count in a table row .
am using following code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// NSInteger WeekList=[WeekArry count];
}
NSInteger row = indexPath.row;
cell.textLabel.text=[NSString stringWithFormat:@"Week %ld",(long)row];
NSLog(@"row%ld",(long)indexPath.row);
// Configure the cell...
return cell;
}
Upvotes: 0
Views: 661
Reputation: 89
if (row == array.count) {
cell.textLabel.text=[NSString stringWithFormat:@"Week %ld",(long)row];
}else{
cell.textLabel.text=[NSString stringWithFormat:@"Week %ld",(long)row + 1];
}
Upvotes: 1