I have an NSArray with 5 objects.
NSArray *tmpArry2 = [[NSArray alloc] initWithObjects:@"test1", @"test2", @"test3", @"test4", @"test5",nil];
I have a table with 4 sections (see screenshot)
What I want to do is show
- test1 in 1st section
- test2 and test3 in 2nd sections
- test4 in 3rd section
- test5 in 4th section
Here’s the problem that I have the index.row and index.section for each of them goes from
indexPath.row: 0 ... indexPath.section: 0
indexPath.row: 0 ... indexPath.section: 1
indexPath.row: 1 ... indexPath.section: 1
indexPath.row: 0 ... indexPath.section: 2
indexPath.row: 0 ... indexPath.section: 3
I was hoping to use the indexPath.section to get to value in tmpArry2 but I am not sure how I can do that. I thought about creating a global static int counter = 0; and keep incrementing it in cellForRowAtIndexPath but the problem is that if I scroll up and down the values keep jumping between cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSLog(@"Inside cellForRowAtIndexPath");
static NSString *CellIdentifier = @"Cell";
// Try to retrieve from the table view a now-unused cell with the given identifier.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// If no cell is available, create a new one using the given identifier.
if (cell == nil)
{
// Use the default cell style.
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSLog(@"indexPath.row: %d ... indexPath.section: %d ...", indexPath.row, indexPath.section);
//this will not give me right results
//NSString *titleStr2 = [tmpArry2 objectAtIndex:indexPath.section];
}

The following code should help, but I did not understand why do you have titles in tmpArry2 and in cellForRowAtIndexPath method countDownArray? I assume you rename it in somewhere in your code.
if you place the following code in you cellForRowAtIndexPath method, it should work.