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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:09:37+00:00 2026-06-17T13:09:37+00:00

I have this data that I need to put inside my UITableView but I’m

  • 0

I have this data that I need to put inside my UITableView but I’m getting confused on how to properly implement it. I cannot properly separate the values to segregate the Boys data to the Girls data.

{
"QUERY": {
    "COLUMNS": [
        "NAME",
        "GENDER"
    ],
    "DATA": [
    [
        "Anne",
        "Girl"
    ],
    [
        "Alex",
        "Boy"
    ],
    [
        "Vince",
        "Boy"
    ],
    [
        "Jack",
        "Boy"
    ],
    [
        "Shiela",
        "Girl"
    ],
    [
        "Stacy",
        "Girl"
    ]
  ]
},
"TOTALROWCOUNT": 6
}

I have this codes:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [genderArray count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return [genderArray objectAtIndex:section];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [namesArray count];
}

namesArray has all the values returned by NAME while genderArray has all the values of GENDER. I’m getting confused.

  • 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-17T13:09:38+00:00Added an answer on June 17, 2026 at 1:09 pm

    AS you are getting confused, break your data into pieces. You want two arrays, one per section. So you want one array of boys names, and another array of girls names.

    You can obtain this by iterating through the embedded DATA array.

    Turn your data into an NSDictionary object. Your data looks like JSON so…

        NSDictionary* myDict =  [NSJSONSerialization JSONObjectWithData:myJsonData 
                                                                options:0 error:&error];
    

    Extract the data…

        NSArray* dataArray = [myDict objectForKey:@"DATA"];
    

    Iterate…

        NSMutableArray* boys = [[NSMutableArray alloc] init];
        NSMutableArray* girls = [[NSMutableArray alloc] init];
        for (id person in dataArray) {
             if ([[person objectAtIndex:1] isEqualToString:@"Girl"])
                  [girls addObject:[person objectAtIndex:0]];
             else [boys  addObject:[person objectAtIndex:0]]; 
         }
    

    Now you have two arrays, one for each of your table sections. Make an array of sections, and put these arrays into it:

        NSArray* sections = [NSArray arrayWithObjects:boys,girls,nil];
    

    Make a separate array for your section headers:

        NSArray* headers = [NSArray arrayWithObjects:@"Boys",@"Girls",nil];
    

    Now your data source methods look like this:

        - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
        {
            return [sections count];
        }
    
        - (NSString *)tableView:(UITableView *)tableView 
        titleForHeaderInSection:(NSInteger)section
        {
            return [headers objectAtIndex:section];
        }
    
        - (NSInteger)tableView:(UITableView *)tableView 
         numberOfRowsInSection:(NSInteger)section
        {
            return [[sections objectAtIndex:section] count];
        }
    

    and finally

    - (UITableViewCell *)tableView:(UITableView *)tableView 
              cellForRowAtIndexPath:(NSIndexPath *)indexPath
    
        ...
    
           cell.textLabel.text = (NSString*)[[self.sections objectAtIndex:indexPath.section]   
                                                            objectAtIndex:indexPath.row];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of data that is <106x25 double> but this is inside
I have a data object that is deep-cloned using a binary serialization. This data
I have this script that collects data from users and I want to check
I have this SQL Query that pulls data from 3 tables. I am unable
I have this function in jQuery that gets data from a page with POST,
I have this following setup, a textarea named with some data in it that
I have text stored in SQL as HTML. I'm not guaranteed that this data
I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study:
I have a data that looks like this . And I intend to create
I have a data that looks like this . And my code below simply

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.