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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:28:32+00:00 2026-05-17T06:28:32+00:00

I have a dictionary that hold address details, sometimes it can hold, ‘name, email,

  • 0

I have a dictionary that hold address details, sometimes it can hold, ‘name, email, telephone’ other times, just ‘name, mobile’

name = "Someone";
email = "Someone@somewhere.com";
telephone = "01000 000000";

or

name = "Someone Else";
mobile = "07700 000000";

I want to display these in a detail table view, in my head this makes sense (I know the below code doesn’t work, but I don’t know any other way of displaying what I want to happen):

if(selectedData objectForKey=@"name" at indexPath.row){
        cell.textLabel.text = @"Name";
        cell.detailTextLabel.text = [selectedData objectForKey:@"name"];
    } else if(selectedData objectForKey=@"email" at indexPath.row){
        cell.textLabel.text = @"Email";
        cell.detailTextLabel.text = [selectedData objectForKey:@"email"];
    } else if(selectedData objectForKey=@"telephone" at indexPath.row){
        cell.textLabel.text = @"Telephone";
        cell.detailTextLabel.text = [selectedData objectForKey:@"telephone"];
    } else if(selectedData objectForKey=@"mobile" at indexPath.row){
        cell.textLabel.text = @"Mobile";
        cell.detailTextLabel.text = [selectedData objectForKey:@"mobile"];
    } 

But I can’t seem to get this coded correctly, and I might even be barking up the wrong tree!
Any help or pointers on this welcome.

  • 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-17T06:28:33+00:00Added an answer on May 17, 2026 at 6:28 am

    I have managed to sort this by first adding an array of all the keys within viewdidload:

    arrayOfKeys = [[NSMutableArray alloc]init];
        for (NSString *key in [selectedData allKeys]){
             NSLog(@"Key:%@", key);
            if(key != @"title" && key != @"name"){
                [arrayOfKeys addObject:key];
            }
        }
    

    Then within cellForRowAtIndexPath I used:

    NSString *currentKey = [arrayOfKeys objectAtIndex:indexPath.section]; 
        if(currentKey == @"email"){
            cell.textLabel.text = @"Email";
            cell.detailTextLabel.text = [selectedData objectForKey:@"email"];
        } else if(currentKey== @"telephone"){
            cell.textLabel.text = @"Telephone";
            cell.detailTextLabel.text = [selectedData objectForKey:@"telephone"];
        } else if(currentKey == @"mobile"){
            cell.textLabel.text = @"Mobile";
            cell.detailTextLabel.text = [selectedData objectForKey:@"mobile"];
        } else if(currentKey == @"company"){
            cell.textLabel.text = @"Company";
            cell.detailTextLabel.text = [selectedData objectForKey:@"company"];
        }
    

    PS. don’t forget to set ‘arrayOfKeys’ in your header file.

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

Sidebar

Related Questions

I have a Dictionary of Classes where the classes hold attributes that are lists
I have a few classes that hold references to other classes through IDictionary instance
I have a dictionary that has a place name as a key and as
I have a dictionary that hosts diameter(in mm) and worth of euro coins: CoinsDiameters
Is it possible to clear a Flex flash.utils.Dictionary ? I have a Dictionary that
I'm newish to Python (and stackoverflow)...bear with me! I have a dictionary that looks
I have a Dictionary object that is formed using a double as its key.
I have a dictionary of strings that i want the user to be able
I have data in a python dictionary that I'd like to store in a
Have Dictionary <Int64, byte> that gets used a lot. I mean in a loop

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.