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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:45:14+00:00 2026-05-28T01:45:14+00:00

I am tring to populate a picker from a dictionary, and i have a

  • 0

I am tring to populate a picker from a dictionary, and i have a dictionary

NSMutableArray* type1names = [NSMutableArray arrayWithObjects:@"--",@"AA",@"AB",@"BA",@"BB",@"BC",@"CB",@"CC",@"CD",@"DC",@"DD",@"FF",nil];
    NSMutableArray* type1points = [NSMutableArray arrayWithObjects:@"-",@"4",@"3.7",@"3.3",@"3.0",@"2.7",@"2.3",@"2.0",@"1.7",@"1.3",@"1",@"0", nil];
    NSMutableDictionary *type1  = [[NSMutableDictionary alloc] initWithObjects:type1points forKeys:type1names];

initialized like this. The problem occurs when i try to get them back as i put them into the Dictionary with the code below.

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    YOHAppDelegate *app = [UIApplication sharedApplication].delegate;

    NSString *key = [[app.pointsDictionary allKeys] objectAtIndex:row];
    return key;
}

They come back from dictionary unordered. Not random, always in same positions, but without any logical system.

Is there a way to implement this, or should i use multiple arrays for this?

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

    A Hot Licks said, NSDictionary does not save the order. However Matt Gallagher shows how to create an OrderedDictionary by subclassing NSMutableDictionary.

    On the other hand you should take his warning seriously. But the certain way, he subclasses it gives us a pattern, that can be used without subclassing: You can define a class, that holds an dictionary and an array, but inherits from NSObject. Define a setObjectForKey: method, that forwards to NSDictionary and add the object to the array (just, if it wasn’t present in the dictionary). Add an method objectForKey:, that forwards to the dictionary and objectAtIndex: that forwards to the array.

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

Sidebar

Related Questions

I'm wondering if there's any way to populate a dictionary such that you have
I'm trying to populate a dictionary dynamically in a for loop like so: pseudo-code
I'm trying to populate a List of beans from a form: public class Foo
I am trying to populate a variable with an XML response from an ajax
I am tring to get a list of dates from my db that will
I'm trying to populate this list with strings from the object data. It comes
Hello I'm trying to populate a mschart from sql but even if the series
iam trying to populate the HyperlinkButton.NavigateUri Property with a string from the properties... But
I'm trying to populate a listview from another class, but I'm geting this error:
I'm trying to populate an array from a dataset with only a specific column

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.