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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:12:16+00:00 2026-05-27T09:12:16+00:00

I am reading a plist file using code below. My problem is that the

  • 0

I am reading a plist file using code below.
My problem is that the file seems to be read in some random order.
The order is always the same (d,b,e,c,a,f).
Is it possible to read the file in the “correct” order, as entered in file?

prefs.plist file content:

<dict>
    <key>a</key>
    <string>1</string>
    <key>b</key>
    <string>2</string>
    <key>c</key>
    <string>3</string>
    <key>d</key>
    <string>4</string>
    <key>e</key>
    <string>5</string>
    <key>f</key>
    <string>6</string>
</dict>

Code:

//Get file name
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"prefs" ofType:@"plist"];

//Load preferences into dictionary
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];

Printout of myDict:

<CFBasicHash 0x4e1f330 [0xe39400]>{type = mutable dict, count = 6,
entries =>
    0 : <CFString 0x4e1f120 [0xe39400]>{contents = "d"} = <CFString 0x4e1f180 [0xe39400]>{contents = "4"}
    1 : <CFString 0x4e1f160 [0xe39400]>{contents = "b"} = <CFString 0x4e1f320 [0xe39400]>{contents = "2"}
    3 : <CFString 0x4e1f130 [0xe39400]>{contents = "e"} = <CFString 0x4e1f190 [0xe39400]>{contents = "5"}
    4 : <CFString 0x4e1f110 [0xe39400]>{contents = "c"} = <CFString 0x4e1f170 [0xe39400]>{contents = "3"}
    5 : <CFString 0x4e1f140 [0xe39400]>{contents = "a"} = <CFString 0x4e1f1a0 [0xe39400]>{contents = "1"}
    6 : <CFString 0x4e1f150 [0xe39400]>{contents = "f"} = <CFString 0x4e1f310 [0xe39400]>{contents = "6"}
}
  • 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-27T09:12:17+00:00Added an answer on May 27, 2026 at 9:12 am

    That’s not necessarily a problem with initWithContentsOfFile:.

    If that’s your intent and your dictionary, simply create an ordered array, like so:

    NSArray * keys = [myDict keys]; 
    NSArray * orderedKeys =
     [keys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
    

    of course, you could use an compare or define your own to order them.

    Then you can enumerate through the ordered keys like an array.

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

Sidebar

Related Questions

I have a plist file that I am reading out a measurement, but some
I am reading in a pList file that I created. It has a list
I'm having problems reading and writing to a plist file. I can read the
When I am creating a simple application for plist shown in below link: http://iosdevelopertips.com/data-file-management/reading-a-plist-into-an-nsarray.html
I'm having problem reading from a plist file I have the Settings.plist file saved
I got an schedule in an plist-file, reading the events (read: times) is not
I'm reading in a plist from a web server, generated with some php. When
Apple strongly recommends using the binary plist format when reading large XML-based data sets
I'm working on porting some ancient code (10.2 era) from NSCoding/plist based archiving to
Below is a simple example of how I'm reading from a plist and displaying

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.