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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:58:05+00:00 2026-06-13T20:58:05+00:00

I have a dictionary which I am storing in another dictionary, which itself gets

  • 0

I have a dictionary which I am storing in another dictionary, which itself gets stored in an array, like so:

NSMutableDictionary* sectionHeights = [[NSMutableDictionary alloc]initWithObjectsAndKeys:
                [NSString stringWithFormat:@"%f", section1Height], @"Section 1 Height",
                [NSString stringWithFormat:@"%f", section2Height], @"Section 2 Height",
        nil];

        [sectionObjects addObject:
         [[NSMutableDictionary alloc] initWithObjectsAndKeys:
          @"Site Inspection Report", @"Form Name",
          @"2", @"Section Count",
          sectionHeights, @"Section Heights",
          nil]
         ];

I pass the array to a property value of another class. When I try to read back sectionHeights, like so, the app crashes:

//get the subSectionData
    NSDictionary* subSectionData = [sectionObjects objectAtIndex:sectionObjects.count-1];
    NSDictionary* sectionHeights = [subSectionData objectForKey:@"Section Heights"];
    for(id obj in sectionHeights) {
        NSLog(@"%@", obj);
    }

in this case sectionHeights has 2 objects, NSStrings which will get converted to floats, but looking at the console output it seems as if the app is trying to output 3 objects:

2012-11-01 10:59:26.338 OAI_Accordion[2402:c07] Section 1 Height
2012-11-01 10:59:26.339 OAI_Accordion[2402:c07] Section 2 Height
2012-11-01 10:59:26.340 OAI_Accordion[2402:c07] -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x9088
2012-11-01 10:59:26.341 OAI_Accordion[2402:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x9088'
*** First throw call stack:
(0x1c95012 0x10d2e7e 0x1d204bd 0x1c84bbc 0x1c8494e 0x46e8 0x2c84 0xfb817 0xfb882 0x4aa25 0x4adbf 0x4af55 0x53f67 0x225b 0x177b7 0x17da7 0x18fab 0x2a315 0x2b24b 0x1ccf8 0x1bf0df9 0x1bf0ad0 0x1c0abf5 0x1c0a962 0x1c3bbb6 0x1c3af44 0x1c3ae1b 0x187da 0x1a65c 0x1e9d 0x1dc5 0x1)
libc++abi.dylib: terminate called throwing an exception

I can’t see where I am setting it up wrong so I was hoping extra sets of eyes on it might 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-13T20:58:07+00:00Added an answer on June 13, 2026 at 8:58 pm

    It looks like your application is crashing because of the loop:

    for(id obj in sectionHeights) {
        NSLog(@"%@", obj);
    }
    

    Which is most likely why you’re getting the error countByEnumeratingWithState:objects:count: as you’re trying to loop through a dictionary of values incorrectly.

    You could loop through your dictionary using enumeration via a block as such:

    [sectionHeights enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop)
    {
        //
        NSLog(@"key: %@ -> value: %@", key, obj);
    }];
    

    This gives you access to the dictionary keys and values side by side. Your previous implementation crashes as the compiler doesn’t know what to do with a dictionary in the context you have provided.

    If you prefer the syntax of fast enumeration, you should loop through the array of dictionary values (or keys if you need them instead) by changing your code to:

    for(id obj in [sectionHeights allValues]) {
        NSLog(@"%@", obj);
    }
    

    You can also use [sectionHeights allKeys] if you need the dictionary keys instead.

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

Sidebar

Related Questions

I have a Dictionary which I am comparing to another Dictionary (variables typed as
I would like to have a dictionary object contains string keys and values, which
I have a dictionary which is keyed by a List: private Dictionary<List<custom_obj>, string> Lookup;
I have the following code: // Dictionary which I want to optimize Dictionary<string, MyClass>
I have a Dictionary<int, string> which I want to take the Key collection into
I have a string data which I need to parse into a dictionary object.
I have a function written in C# which has one parameter type as Dictionary<string
I have a bunch of named value parameters in a Dictionary<string, object> , which
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I have 2 dictionary which contain the same keys but the value pairs are

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.