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

  • Home
  • SEARCH
  • 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 76961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:45:19+00:00 2026-05-10T20:45:19+00:00

This one is a bit tedious in as far as explaining, so here goes.

  • 0

This one is a bit tedious in as far as explaining, so here goes. I’m essentially populating a tableView on the iPhone with multiple sections, and potentially multiple rows per section. To my understanding, it’s best to have an array of arrays so that you can simply determine how many sections one has by sending a message to the top level array of count, then for rows per section, doing the same for the inner array(s). My data is in the form of a dictionary. One of the key/value pairs in the dictionary determines where it will be displayed on the tableView. An example is the following:

{   name: 'bob',   location: 3 } {    name: 'jane',   location: 50 } {   name: 'chris',   location: 3 } 

In this case I’d have an array with two subarrays. The first subarray would have two dictionaries containing bob and chris since they’re both part of location 3. The second subarray would contain jane, since she is in location 50. What’s my best bet in Cocoa populate this data structure? A hash table in C would probably do the trick, but I’d rather use the classes available in Cocoa.

Thanks and please let me know if I need to further clarify.

  • 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. 2026-05-10T20:45:20+00:00Added an answer on May 10, 2026 at 8:45 pm

    The following code works: (edit: added my initialization code)

    NSArray * arrayOfRecords = [NSArray arrayWithObjects:      [NSDictionary dictionaryWithObjectsAndKeys:      @'bob', @'name',       [NSNumber numberWithInt:3], @'location',  nil],      [NSDictionary dictionaryWithObjectsAndKeys:      @'jane', @'name',       [NSNumber numberWithInt:50], @'location',  nil],      [NSDictionary dictionaryWithObjectsAndKeys:      @'chris', @'name',       [NSNumber numberWithInt:3], @'location',  nil],      nil];  NSMutableDictionary * sections = [NSMutableDictionary dictionary];  for (NSDictionary * record in arrayOfRecords) {     id key = [record valueForKey:@'location'];     NSMutableArray * rows = [sections objectForKey:key];      if (rows == nil)     {         [sections setObject:[NSMutableArray arrayWithObject:record] forKey:key];     }     else     {         [rows addObject:record];     } }  NSArray * sortedKeys = [[sections allKeys] sortedArrayUsingSelector:@selector(compare:)]; NSArray * sortedSections = [sections objectsForKeys:sortedKeys notFoundMarker:@''];  NSLog(@'%@', sortedSections);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I think when doing this you should use SetLink instead… May 11, 2026 at 9:49 am
  • added an answer I'd recommend Trac. It's SVN browser looks like the thing… May 11, 2026 at 9:49 am
  • added an answer We have just gone down the route of Windows Server… May 11, 2026 at 9:49 am

Related Questions

This one is a bit tedious in as far as explaining, so here goes.
This is a bit of a weird one, and I could well be coding
This is a bit of a strange one, but I've been struggling for a
Google results on this one are a bit thin, but suggest that it is
This one is a case of not doing your homework.:-) Apart from dynamic loading
This one is weird, I have a page that consists of a html table
This is a follow-up question to this one . Take a look at these
My question is a lot like this one . However I'm on MySQL and
This is a compiler error (slightly changed for readability). This one always puzzled me.
I know this one is going to be a long-shot, but I thought I'd

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.