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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:16:12+00:00 2026-06-15T15:16:12+00:00

im a litte confused by adding two NSMutableArrays to an NSMutableDictonary, one for Keys

  • 0

im a litte confused by adding two NSMutableArrays to an NSMutableDictonary,
one for Keys and one for Objects.
This is working as long the Keys are not the same

If there are even, I only get the last object in my Dict.

If I change my Keys to my Objects and Objects to Keys, everything works fine.

Can anyone help me with that?

Here are my Outputs:

2012-12-08 19:30:40.906 Test[12015:c07] myKeys: (
"Bauchumfang & Gewicht",
"Bauchumfang & Gewicht",
"Stress & Entspannung",
"Stress & Entspannung",
"Mein Rauchverhalten",
"Mein Rauchverhalten",
"Blutdruck & Puls",
"Blutdruck & Puls",
"Blutzucker & Diabetes",
"Blutzucker & Diabetes",
"Meine Stimmung",
"Meine Stimmung",
"R\U00fccken & Bewegung",
"R\U00fccken & Bewegung",
"R\U00fccken & Bewegung",
Schlafrhythmus,
Schlafrhythmus,
"Schrittz\U00e4hler"
)
2012-12-08 19:30:40.907 Test[12015:c07] myObjects: (
"Mein Bauchumfang",
"Mein Gewicht",
"Mein Entspannungsniveau",
"H\U00e4ufigkeit der Entspannungsmomente",
Rauchverhalten,
"Verlangen nach einer Zigarette",
"Systolischer Wert",
"Diastolischer Wert",
"Meine bewusste Ern\U00e4hrung mit Diabetes",
"Meine Blutzucker-Werte",
"Mein Befinden",
"Meine Aktivit\U00e4ten",
"Umsetzung meiner R\U00fccken\U00fcbungen",
"Das Befinden meines R\U00fcckens",
"Meine sportlichen Aktivit\U00e4ten",
"Meine Schlafqualit\U00e4t",
"Mein Energieniveau",
"Meine Schritte"
)
2012-12-08 19:30:40.907 Test[12015:c07] myDictionary: {
"Bauchumfang & Gewicht" = "Mein Gewicht";
"Blutdruck & Puls" = "Diastolischer Wert";
"Blutzucker & Diabetes" = "Meine Blutzucker-Werte";
"Mein Rauchverhalten" = "Verlangen nach einer Zigarette";
"Meine Stimmung" = "Meine Aktivit\U00e4ten";
"R\U00fccken & Bewegung" = "Meine sportlichen Aktivit\U00e4ten";
Schlafrhythmus = "Mein Energieniveau";
"Schrittz\U00e4hler" = "Meine Schritte";
"Stress & Entspannung" = "H\U00e4ufigkeit der Entspannungsmomente";
}

and my implementation:

- (void)objectLoader:(RKObjectLoader *)objectLoader
didLoadObjects:(NSArray *)objects {

  menuItems = [[NSMutableArray alloc]init];
  for (Trackers *trackers in objects) {

    if ([trackers.assigned isEqualToString:@"true"]) {
        [menuItems addObject:[trackers name]];
        [groups addObject:[trackers category]];
    }

  }
  NSLog(@"myKeys: %@", groups);
  NSLog(@"myObjects: %@", menuItems);
  NSMutableDictionary *menuGroups = [[NSMutableDictionary alloc]
  initWithObjects:menuItems forKeys:groups];
  NSLog(@"myDictionary: %@", menuGroups);
  [menuList addObject:menuGroups];
  contentLoaded = YES;
  [settingsTable reloadData];
}

Thx for any help.

  • 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-15T15:16:14+00:00Added an answer on June 15, 2026 at 3:16 pm

    well a dictionary per definition doesnt allow duplicate keys
    upon looking at your code, you want to store N items under the same key.

    to do so you need store an array of items for each key.. UNTESTED example (written inline)

    - (void)objectLoader:(RKObjectLoader *)objectLoader
    didLoadObjects:(NSArray *)objects {
      NSMutableDictionary *menuGroups = [[NSMutableDictionary alloc] init];
      for (Trackers *trackers in objects) {
    
        if ([trackers.assigned isEqualToString:@"true"]) {
            NSMutableArray *array = [menuGroups objectForKey:[trackers category]];
            if(!array) {
                array = [NSMutableArray array];
                [menuGroups setObject:array forKey:[trackers category]];
            }
            [array addObject:[trackers name]];
        }
    
      }
    
    
      contentLoaded = YES;
      [settingsTable reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am litte confused, i want to protect one page in classic asp from
I am currently learning javascript and am a litte confused with passing parameters through
Little confused, the basic spring mvc app has this: app-config.xml <context:component-scan base-package=org.springframework.samples.mvc.basic /> and
I'm a little confused about the rules regarding restricted pointers. Maybe someone out there
I have two svn repositories, one each for the iOS and Android versions of
I've been working on understanding Javascript objects and namespaces and I am a little
I'm little confused here now. Let me explain: I've seen people talking about adding
I'm adding functionality to one of our existing (but broken) systems. It grabs an
I´m littel confused with this reserve key and cases caused errors. Here a sample
I have 2 lists and am a little confused about adding an object into

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.