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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:18:31+00:00 2026-05-21T11:18:31+00:00

I have an NSMutableDictionary with three key/value pairs. key1 – person object1 key2 –

  • 0

I have an NSMutableDictionary with three key/value pairs.

key1 - person object1 
key2 - person object2 
key3 - person object3

By comparing a string with the key in the dictionary, I need to retrieve the contents of the person object. How can I do this? Please help me. My code is:

NSArray *keys = [persondict allKeys];
    id key;
    for(int i= 0; i<[keys count]; ++i)
    {   key = [keys objectAtIndex:i];
    }
    for(id key in persondict){
        if ([key isEqual:agentrefattr]){
            //how to get the person object here?
            [aperson setPhoneNumber:aperson.PhoneNumber];
            [aperson setEmailAddress:aperson.EmailAddress];
            [aPersonName setGivenName:aPersonName.GivenName];
            [aPersonName setSurname:aPersonName.Surname];
            [aperson setPersonName:aperson.PersonName];

            [self.agentarray insertObject:aperson atIndex:index];
            [self.agentnamearray insertObject:aPersonName atIndex:index];
            aperson = [agentarray objectAtIndex:index];
            aPersonName = [agentnamearray objectAtIndex:index];

            NSLog(@"att:%@",agentrefattr);
            NSLog(@"Email :%@",aperson.EmailAddress);
            NSLog(@"Phone :%@",aperson.PhoneNumber);
            NSLog(@"Given Name :%@",aperson.PersonName.GivenName);
            NSLog(@"SurName :%@",aperson.PersonName.Surname);

Please help me with some hints. I want to access the properties, GivenName, Surname, etc., in the person object.

  • 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-21T11:18:31+00:00Added an answer on May 21, 2026 at 11:18 am

    The keys in a dictionary are unique. So if agentrefattr is a string representing a key, yuu will only ever have one object in the dictionary with that key, so there is no need for a loop at all. Just do this:

    aPerson = [personDict objectForKey: agentrefattr];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a NSMutableDictionary . I have to dynamically rename any Key in
I have an NSMutableDictionary with some song data (for example key: Artist object: Passion
So I have three NSMutableDictionary's like this: .h file NSMutableDictionary *myContainer; NSMutableDictionary *myD1; NSMutableDictionary
I have a NSMutableDictionary of NSMutableSets. Each set entry is a string, something like
I am having a bit of a issue. I have an NSMutableDictionary with 10
I have a main NSMutableDictionary that contains a collection of others NSMutableDictionary. The thing
If I have a mutable array codes in an NSMutableDictionary categorize NSMutableArray *myMutableArray=(NSMutableArray*)[categorize objectForKey:@codes];
I have this retained property declared like this: @property (nonatomic, retain) NSMutableDictionary *codes; then
I've encountered a strage error today. I have an NSArray and an NSMutableDictionary .
I have an Objective-C NSMutableDictionary declared inside a class's @interface section, with getter/setter methods,

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.