user3656071
user3656071

Reputation: 3

how to display number from 1 to array count in IOS 7?

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

Answers (1)

Awais Chatha
Awais Chatha

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

Related Questions