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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:57:07+00:00 2026-05-16T06:57:07+00:00

Please tell me how can we have multiple values for the same key in

  • 0

Please tell me how can we have multiple values for the same key in NSMutableDictionary?

When I use the below approach, the values are being replaced with the recent one.

In my case:

[dictionary setObject:forename forKey:[NSNumber numberWithint:code]];
[dictionary setObject:surname forKey:[NSNumber numberWithint:code]];
[dictionary setObject:reminderDate forKey:[NSNumber numberWithint:code]];

When I view the contents of the dictionary, I get only the reminderDate for key code. Here, the code is same for all values. How do I avoid forename and surname being replaced by plannedReminder.

Thank You!

  • 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-16T06:57:08+00:00Added an answer on May 16, 2026 at 6:57 am

    It seems like you are using code as the key and you want to represent multiple values based on code. In that case, you should either:

    1. Abstract all data associated with code into a separate class (perhaps called Person) and use instances of this class as values in the dictionary.

    2. Use more than one layer of dictionaries:

      NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
      
      NSMutableDictionary *firstOne = [NSMutableDictionary dictionary];
      [firstOne setObject:forename forKey:@"forename"];
      [firstOne setObject:surname forKey:@"surname"];
      [firstOne setObject:reminderDate forKey:@"reminderDate"];
      
      [dictionary setObject:firstOne forKey:[NSNumber numberWithInt:code]];
      
      // repeat for each entry.
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a Jersey Resource class. Can someone please tell me how can
1)Can Any one please tell me what are the prerequisites have been installed on
Can anyone please tell why this error? I have included everything ( all header,
Can you please tell me how can I use valgrind for memory profile? The
Can someone please tell me how to use the group by clause, grouping by
Can anyone please tell me how to add multiple spinners with only one onItemSelected().
Please tell me how can I get array of all Those DIV of specific
Please tell me how can i activate the Sun JavaME memory monitor within eclipse
can anyone please tell me how can i retrieve data in jquery when i
Can you please tell me how can I set a global #define in my

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.