Is NSArray / NSMutableArray order guaranteed when reading array from plist?
Asked Answered
T

1

10

I have a plist containing an array, with a number of items that I wan't maintained in a particular order.

When I create an NSArray from the plist, will the array have the objects in the same order as the plist? For example. If I execute the code like the following, will the array have the items in the same order as the plist?

NSMutableDictionary* plistDictionary = [self someMethodToReadThePlistAsDictionary:plistName];
NSArray* array = [plistDictionary objectForKey:@"arrayKey"];

Is there any documentation where I can verify this? In practice it seems to be the case, but I would like to verify it somehow.

EDIT: I seem to be getting down votes for this question, so let me clarify: I am fully aware that an array maintains insertion order. My question has to do with "plists", since I am unaware of what happens to a plist when it becomes an object.

Tatter answered 31/1, 2012 at 9:58 Comment(0)
T
20

The answer is yes, the order of the elements of an array will be maintained - because an array is an ordered collection of items, just like a string is an ordered sequence of characters...

Tamishatamma answered 31/1, 2012 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.