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 7558095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:17:16+00:00 2026-05-30T12:17:16+00:00

i want a titleHeaderForInSection but i’m doing something wrong my code: self.List = [[NSArray

  • 0

i want a titleHeaderForInSection but i’m doing something wrong my code:

 self.List = [[NSArray alloc]
                   initWithObjects: 
                   @"2", 

                   nil];


    self.List2 = [[NSArray alloc]
                   initWithObjects: 
                   @"1", 

                   nil];

and;

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



        // Configure the cell...
        cell.textLabel.text = [self.List objectAtIndex:[indexPath row]];

        cell.textLabel.text = [self.List2 objectAtIndex:[indexPath row]];




    }
    return cell; 
}

Is something like this possible? It’s now showing me only ‘1’

cell.textLabel.text = [self.List objectAtIndex:[indexPath row]];
cell.textLabel.text = [self.List2 objectAtIndex:[indexPath row]];

A screenshot:

![enter image description here][1]

The problem is that under TitleHeaderForSection ‘A’ i want ‘2’ and under TitleHeaderForSection ‘B’ i want the number 1

https://i.stack.imgur.com/9uD2Q.png

Edit:

i’m using the code but a strange thing i have;

    self.List = [[NSArray alloc]
                       initWithObjects: 
    @"1", 
    @"2", 
    @"3", 
    @"4", 
                       nil];


        self.List2 = [[NSArray alloc]
                       initWithObjects: 
     @"5", 
     @"6", 
     @"7", 
     @"8", 
 nil];
       self.List3 = [[NSArray alloc]
                       initWithObjects: 
    @"9", 
    @"10", 
    @"11", 
    @"12", 
 nil];
       self.List4 = [[NSArray alloc]
                       initWithObjects: 
    @"13",
    @"14", 
    @"15", 
    @"16",  
 nil];

and:

 if(indexPath.section == 0)
        {
            cell.textLabel.text = [self.List objectAtIndex:[indexPath row]];

        }
        else if (indexPath.section == 1)
        {
            cell.textLabel.text = [self.List2 objectAtIndex:[indexPath row]];       
        }
        else if (indexPath.section == 2)
        {
            cell.textLabel.text = [self.List3 objectAtIndex:[indexPath row]];       
        }
        else if (indexPath.section == 4)
        {
            cell.textLabel.text = [self.List4 objectAtIndex:[indexPath row]];       
        }

//

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    // Return the number of rows in the section.


     switch (section) {

         case 0:
             return [self.List count];

         case 1:
             return [self.List2 count];

         case 2:
             return [self.List3 count];

         case 3:
             return [self.List4 count];

         default:
             return 0;
     }


}

But after TitleHeaderForSection ‘B’ this is wat happend instead of 9/10/11/12 and under D 13/14/15/16 it’s showing:

https://i.stack.imgur.com/LuYOx.png

  • 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-05-30T12:17:17+00:00Added an answer on May 30, 2026 at 12:17 pm

    you are messing this up

    do this

    if(indexPath.section == 0)
    {
    cell.textLabel.text = [self.List objectAtIndex:[indexPath.row]];
    
    }
    else
    {
    cell.textLabel.text = [self.List2 objectAtIndex:[indexPath.row]];
    }
    

    Right now you first assign the value 2
    in line

    cell.textLabel.text = [self.List objectAtIndex:[indexPath row]];
    

    and then 1

    in this line

    cell.textLabel.text = [self.List2 objectAtIndex:[indexPath row]];
    

    So in the end you always get 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

want to ask user to input something but not want to wait forever. There
Want the function to sort the table by HP but if duplicate HPs then
Want to code a key pad for an calculator. What I want to make
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
I want a TitleHeaderForSection after case 3 (example) (TableView). Is Something like this possible:
Want to attach an Event Handler/Listener to some links using the delegate() method, but
want to query below xml <courseList filedUnder=Courses> <category code=4wd title=4wd Operation> <product code=lr title=4wd
Want to pass 4 values in AJAX parameter.First three are passing properly but the
Want to make a vocabulary list in HTML & CSS that looks like this:
Want to find piece of the code, written in python, which adds a new

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.