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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:11:00+00:00 2026-06-08T14:11:00+00:00

I have a NSDictionary that contains multiple keys with the same name. Here is

  • 0

I have a NSDictionary that contains multiple keys with the same name. Here is the structure:

Dictionary {

    "Text" => "Blah",
    "Text" => "Blah 2",
    "Text" => "Blah 3"

}

So there are three keys with the same name Text. I put the values of Text into a NSMutableArray using:

NSDictionary *notes = [d objectForKey:@"notes"]; //dictionary above
NSMutableArray *notesA = [notes valueForKey:@"Text"];
NSLog(@"%i", notesA.count);

However, when I try to get the number of items in the array, it crashes with the following error:

-[__NSCFString count]: unrecognized selector sent to instance 0x856c110

Any idea why this is happening? I am able to output the values of the NSMutableArray and see them, but can’t count them.


Here is the XML file:

<tickets>
 <text>Blah</text>
 <text>Blah 2</text>
 <text>Blah 3</text>
</tickets>

Notes dictionary output:

(
        {
        text = "Blah";
    },
        {
        text = "Blah 1";
    },
        {
        text = "Blah 2";
    }
)
  • 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-08T14:11:02+00:00Added an answer on June 8, 2026 at 2:11 pm

    You are adding NSStrings as objects, not a NSArray.

    NSDictionary *notes = [NSDictionray dictionaryWithObjectsAndKeys:[NSMutableArray arrayWithObjetcs:@"Blah",@"Blah 2", @"Blah3"],@"Text",nil];
    
    NSMutableArray *notesA = [notes objectForKey:@"Text"];
    NSLog(@"%i", [notesA count]);
    

    As we are using a NSMutableArray, this would be valid too:

    NSDictionary *notes = [NSDictionray dictionaryWithObjectsAndKeys:[NSMutableArray array],@"Text",nil];
    
    NSMutableArray *notesA = [notes objectForKey:@"Text"];
    [notesA addObject:@"Blah"];
    [notesA addObject:@"Blah 2"];
    [notesA addObject:@"Blah 3"];
    NSLog(@"%i", [notesA count]);
    

    BTW:

    Dictionary {
    
        "Text" => "Blah",
        "Text" => "Blah 2",
        "Text" => "Blah 3"
    
    }
    

    This is not a valid NSDictionary structure, as keys have to be unique.

    What you want is:

    Dictionary {
        "Text" => ["Blah", "Blah 2","Blah 3"]    
    }
    

    If you set several objetcs for the same key, the older object will be replaced by the newer.


    When the parser parses the tickets tag, it should create a array which it uses to add the single texts.


    (
            {
            text = "Blah";
        },
            {
            text = "Blah 1";
        },
            {
            text = "Blah 2";
        }
    )
    

    Your notes object isnt a dictionary. it is an array with 3 dictionaries in it. each has an key text and some blah value.

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

Sidebar

Related Questions

I have an NSArray which contains NSDictionary objects with keys that are NSNumber objects.
I have about 20,000 NSDictionary s. Each dictionary contains three NSString s. The dictionaries
I have a NSDictionary that contains data converted from json data, like {message_id:21} .
I have a class that contains an NSDictionary and periodically, I have a thread
I have a UIScrollView that contains a bunch of views: for(NSDictionary* deal in deals)
I created a plist that contains an NSDictionary structure. The key is a label
I have a BankAccount model class that contains data like account number, bank name,
I have an NSDictionary that holds all the data: One title (not important for
I have a simple NSDictionary that I am trying to populate with data from
I have a class that conforms to UISearchDisplayDelegate and contains a UISearchBar. This view

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.