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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:04:59+00:00 2026-05-27T20:04:59+00:00

here is my dictionary and its values NSMutableDictionary *myDic=[NSMutableDictionary Dictionary]; [myDIC setObject:@]; [myDIC setObject:string1

  • 0

here is my dictionary and its values

NSMutableDictionary *myDic=[NSMutableDictionary Dictionary];
[myDIC setObject:@""];

[myDIC  setObject:string1 forKey:key1];
[myDIC  setObject:string2 forKey:key2];
[myDIC  setObject:string3 forKey:key3];

so up to here i have filled up my dictionary.now i want to read them through a for loop.

for (NSString *key in myDic ){


}

here is my problem! inside this loop the my first key will be key1 but i seems it start from the last key that i have set before!

is there anyone who can tell me why ? and how i can meet my expectation as what i explained?

  • 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-27T20:05:00+00:00Added an answer on May 27, 2026 at 8:05 pm

    NSDictionary is not an index base collection it’s a Hashtable, and like all HashTable, the elements are store according to some logic base on some Hash that you don’t know. If you look in the documentation for NSDictionary you will find a sentence that state that there is not guaranty about the order into which the item will be retrieve.
    If you want your key to be retrieve in a specific order you will need to keep your keys in an NSArray, in the order that you want them.


    Or you can sort your keys when you need them.

    NSArray * allKeys = [myDict allKeys];
    allKeys = [allKeys sortedArrayUsing//  [see the documentation for all options][1] ]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an enum with a whole bunch of values (only three shown here):
Here is a command line script for a dictionary lookup using Wordnet: #!/bin/bash #
I've got this python dictionary mydict, containing arrays, here's what it looks like :
In the following code: //anArray is a Array of Dictionary with 5 objs. //here
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
I made a dictionary, then split up the values and keys into lists and
I am working in c# with .net 2.0 (i know its old) Here is
Take a look at this piece of code - (NSMutableDictionary *)getUsersFromServer { //here we're

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.