从 plist 读取数组时,NSArray / NSMutableArray 顺序是否得到保证?
我有一个包含数组的 plist,其中有许多我不想按特定顺序维护的项目。
当我从 plist 创建 NSArray 时,该数组的对象顺序是否与 plist 相同?例如。如果我执行如下代码,数组中的项目是否与 plist 的顺序相同?
NSMutableDictionary* plistDictionary = [self someMethodToReadThePlistAsDictionary:plistName];
NSArray* array = [plistDictionary objectForKey:@"arrayKey"];
有任何文件可以验证这一点吗?在实践中似乎是这样,但我想以某种方式验证一下。
编辑:我似乎对这个问题投了反对票,所以让我澄清一下:我完全意识到数组维护插入顺序。我的问题与“plist”有关,因为我不知道当 plist 成为对象时会发生什么。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是肯定的,数组元素的顺序将被保持 - 因为数组是项目的有序集合,就像字符串是字符的有序序列一样......
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...