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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:46:59+00:00 2026-05-30T01:46:59+00:00

I’m new to iOS dev and I followed a tutorial that was a simple

  • 0

I’m new to iOS dev and I followed a tutorial that was a simple UITableview and a detail view.

This sets up my Array:

- (void)viewDidLoad
{
    [self setupArray];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)setupArray
{
    states = [[NSMutableDictionary alloc]init];
    [states setObject:@"Thing 1" forKey:@"Subject 1"];
    [states setObject:@"Thing 2" forKey:@"Subject 2"];
    [states setObject:@"Thing 3" forKey:@"Subject 3"];
    [states setObject:@"Thing 4" forKey:@"Subject 4"];

    datasource = [states allKeys];
}

I have working cells and detail views. How do I add more objects to my keys? Is that possible? I need each subject [key] to have many attributes (i.e. a thing, a person, a place, a color)…

Can you break this down to the most simple terms for me? Thanks!

  • 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-30T01:47:00+00:00Added an answer on May 30, 2026 at 1:47 am

    I’m not sure if I understand your question, but each key can have only one object associated with it. In your case, you’re using an NSString object. If you replaced the NSString with some object that you create, say AnObjectWithAThingAndAPersonAndAPlace, you could have multiple attributes associated with each key.


    I think I understand what you want now. What you want is not an object with arrays associated to it, but an array of objects. You can do it with NSDictionary objects.

    - (void)setupArray
    {
        NSMutableArray *objectArray = [[NSMutableArray alloc] init];
    
        NSMutableDictionary *object1 = [[NSMutableDictionary alloc] init];
        [object1 setObject:@"Apple" forKey:@"thing"];
        [object1 setObject:@"Alex" forKey:@"person"];
        [object1 setObject:@"Alabama" forKey:@"place"];
        [object1 setObject:@"Azure" forKey:@"color"];
        [objectArray addObject:object1];
    
        NSMutableDictionary *object2 = [[NSMutableDictionary alloc] init];
        [object2 setObject:@"Banana" forKey:@"thing"];
        [object2 setObject:@"Bill" forKey:@"person"];
        [object2 setObject:@"Boston" forKey:@"place"];
        [object2 setObject:@"Blue" forKey:@"color"];
        [objectArray addObject:object2];
    
        datasource = [NSArray arrayWithArray:objectArray];
    }
    

    Then in your UITableViewDataSource method

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSInteger row = [indexPath row];        
        NSDictionary *object = [datasouce objectAtIndex:row];
    
        ...
    
    }
    

    and you can retrieve all the strings for that object.

    If I were to do something like this, I would probably create a plist file containing the array. Then your setupArray method could look like this:

    - (void)setupArray
    {
        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"YourFileName" ofType:@"plist"];
        NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:filePath]; 
        datasource = (NSArray*)[plistData objectForKey:@"ObjectsForTableView"];
    }
    

    I though I would add a few more comments…In case it isn’t obvious, the objects you add to your dictionary don’t have to be NSStrings, they can be any object, such as an NSNumber, which may be useful for you in the case of your baseball players. Also, you may wish to create a custom player object instead of using an NSDictionary. And you may want to have something like a Core Data database where the players are stored and retrieved (instead of hard coding them or getting them from a plist file). I hope my answer can get you started on the right path though.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,

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.