Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:46:35+00:00 2026-06-17T17:46:35+00:00

I have an NSArray with 5 objects. NSArray *tmpArry2 = [[NSArray alloc] initWithObjects:@test1, @test2,

  • 0

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];


}

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:46:36+00:00Added an answer on June 17, 2026 at 5:46 pm

    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.

    NSInteger index = 0;
    for (int i = 0; i < indexPath.section; i++) {
        index += [self tableView:self.tableView numberOfRowsInSection:i];
    }
    index += indexPath.row;
    cell.textLabel.text = [countDownArray objectAtIndex:index];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this method - NSArray *objects = [NSArray arrayWithObjects:appDelegate.UserID,itemName.text,@1,@1,itemDegem.text,itemDescription.text, nil]; NSArray *keys =
I have an NSArray with objects : NSArray *array = [NSArray arrayWithObjects:@Saturday,@Sunday,@Monday,@tuesday,@Wednesday,@thursday,nil]; and some
for an iOS 5.0 application using ARC, i have an NSArray of objects that
I have an NSArray of double objects.... I currently I have a for loop
I have an NSArray of (Product) objects that are created by parsing an XML
I have an NSArray of NSDictionary objects which I would like to be able
So I have an NSArray with custom objects called Church. And in each church
Example: I have an NSArray with 40 objects. What is the most efficient way
i have an NSArray which contains custom objects, the objects have an NSString property,
I have some NSDictionary objects stored in an NSArray called telephoneArray . I fetch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.