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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:03:52+00:00 2026-05-23T02:03:52+00:00

I am writing an iPhone app using S7Graphview and I have saved some dates

  • 0

I am writing an iPhone app using S7Graphview and I have saved some dates and results to a .plist as keys and values in a dictionary, both as strings. My plist looks like this:

<dict>
<key>2011-05-11</key>
<string>23</string>
<key>2011-05-12</key>
<string>23</string>
<key>2011-05-13</key>
<string>23</string>
<key>2011-05-14</key>
<string>43</string>
<key>2011-06-14</key>
<string>43</string>
</dict>

Then I use this loop to load those values into the graphview:

NSMutableDictionary* dictionary = [[NSMutableDictionary alloc]init];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) 
    dictionary = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
int i = 1;        

if ([dictionary count] > 0) {
for (NSString* key in dictionary){
    NSString* verdiString = [dictionary objectForKey:key];
    CGFloat verdi = [verdiString intValue];
    NSDate *dato = [[NSDate alloc]init];
    NSLog(@"key=%@ value=%@", key, [dictionary objectForKey:key]);
    dato = [self stringTilDato:key];
    [items.list_ addObject:[[GraphInfo alloc] initWithID:i name:verdiString value:verdi date:dato]];
    i++;
}
}

The “stringTilDato” method converts the date string to a NSDate. The values get loaded into the items.list, but in the wrong order! The NSLog reports:

key=2011-05-14 value=43
key=2011-05-13 value=23
key=2011-05-12 value=23
key=2011-06-14 value=43
key=2011-05-11 value=23
key=2011-05-14 value=43
key=2011-05-13 value=23
key=2011-05-12 value=23
key=2011-06-14 value=43
key=2011-05-11 value=23

(Don’t know why it goes through the keys twice, btw, but I dont’t believe that’s important). I thought the keys would be read alphabetically, or at least in the order of the plist. Why does the plist get loaded into the dictionary in this order, or is it my loading loop that is the problem?

Hope there is someone out there who can help me 🙂

  • 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-23T02:03:53+00:00Added an answer on May 23, 2026 at 2:03 am

    A dictionary is not an ordered data structure. You can assume no particular order of the keys, and adding or removing a key can change the order completely. If you need an ordered data structure then use an array, or after getting all the keys sort them.

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

Sidebar

Related Questions

I am writing an app for the iPhone using cocos2d where I have 4
I am writing an app for the iPhone using cocos2d where I have 4
I'm writing an iPhone App that relies on getting the device location. Management have
I am writing an iPhone app – a client for some social network. The
I'm writing an iPhone app for a client, and they have requested a feature
I have a 32bit iMac that I am writing an iPhone app in Xcode
I'm writing a Navigation-Based iPhone app, and I'd like to have a UIToolBar docked
I'm writing a reminders app for iPhone that displays reminders using local notifications. If
I am writing a game for the iPhone/iPodTouch (using Cocos2d) and I have noticed
I'm writing an iPhone app using Appcelerator Titanium Mobile. I am hiding and showing

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.