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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:37:26+00:00 2026-05-18T00:37:26+00:00

My aim is to produce an array, which I can use to add section

  • 0

My aim is to produce an array, which I can use to add section headers for a UITableView. I think the easiest way to do this, is to produce a sections array.

I want to create section headers for dates, where I’ll have several or no rows for each.

So in my populate data array function, I want to populate a display array. So record 1, look for the first date in my display array, create a new array item if it doesn’t exist, if it does exist add 1 to the count.

So I should end up with something like this.

arrDisplay(0).description = 1/June/2001; arrDisplay(0).value = 3;
arrDisplay(1).description = 2/June/2001; arrDisplay(1).value = 0;
arrDisplay(2).description = 3/June/2001; arrDisplay(2).value = 1;
arrDisplay(3).description = 5/June/2001; arrDisplay(3).value = 6;

My question is how do I create and use such an array with values, where I can add new elements of add to the count of existing elements and search for existing elements ?

  • 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-18T00:37:27+00:00Added an answer on May 18, 2026 at 12:37 am

    I think, if i understand you, an NSMutableDictionary would work. (as NR4TR said) but, i think the object would be the description and the key would be the count. you could check for the key and get the count in the same gesture. if the return value of objectForKey is nil, it doesn’t exist.

    NSMutableDictionary *tableDictionary = [[NSMutableDictionary alloc] init];
    
    NSString *displayKey = @"1/June/2001";
    
    NSNumber *displayCount = [tableDictionary objectForKey:displayKey];
    
    if (displayCount != nil) {
     NSNumber *incrementedCount = [[NSNumber alloc] initWithInteger:[displayCount integerValue] + 1];
     [tableDictionary removeObjectForKey:displayKey];
     [tableDictionary setValue:incrementedCount
          forKey:displayKey];
     [incrementedCount release];
    }
    else {
     NSNumber *initialCount = [[NSNumber alloc] initWithInteger:1];
     [tableDictionary setValue:initialCount
          forKey:displayKey];
     [initialCount release];
    }
    

    EDIT: Hopefully this isn’t pedantic, but I think a couple pointers will help.

    Dictionaries, Sets, and Arrays all hold objects for retrieval. The manner of holding and retrieval desired drives the decision. I think of it based on the question ‘what is the nature of the information that I have when I need an object being held?’

    NSDictionary and NSMutableDictionary

    • Hold n objects per key. (I think…I haven’t had to test a limit, but i know you can get an NSSet back as a value.)
    • KEY is more important than INDEX. I don’t think of dictionaries as ordered. they know something and you need to ask the correct question.

    NSArray and NSMutableArray

    • hold n objects in order.
    • INDEX is most important bit of information. (you can ask for the index of an object but, even here, the index is the important part)
    • you will typically drive table views with an array because the ordered nature of the array fits.

    NSSet, NSMutableSet, and NSCountedSet

    • A collection of objects without order.

    You can change any of these into the other with something like [nsset setFromArray:myArray];

    and all of these things can hold the other as objects. I think an array as your top level is the correct thinking, but beyond that, it becomes an issue of implementation

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

Sidebar

Related Questions

When developing a new web based application which version of html should you aim
My Aim: Sending an email (e.g. support request, error report) out of a C#
Does anyone know of any existing projects that aim to port Android's Java VM
SVN and CVS are two very different systems that aim to address the same
I'm trying to find any JavaScript frameworks whose sole aim is to standardize the
I am developing a system as an aid to musicians performing transcription. The aim

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.