Objective c NSDictionary Dictionary WithContentsOfFile未按顺序加载数据

Objective c NSDictionary Dictionary WithContentsOfFile未按顺序加载数据,objective-c,plist,nsdictionary,Objective C,Plist,Nsdictionary,我正在尝试将一些数据从plist加载到数组中 NSDictionary* mydictionary = [ NSDictionary dictionaryWithContentsOfFile:[ [ [ NSBundle mainBundle] bundlePath ] stringByAppendingPathComponent:@"MyLevels.plist" ] ]; NSMutableArray *panelNames1;

我正在尝试将一些数据从plist加载到数组中

NSDictionary* mydictionary = [ NSDictionary dictionaryWithContentsOfFile:[ [ [ NSBundle      mainBundle] bundlePath ] stringByAppendingPathComponent:@"MyLevels.plist" ] ];

NSMutableArray *panelNames1;                                                         
panelNames1 = [[NSMutableArray alloc] init];

for (id theKey in mydictionary) {        
    [panelNames1 addObject:[mydictionary objectForKey:theKey]]; 
}
但它的输出顺序似乎与数组中MyLevels.plist的输出顺序不同

MyLevels.plist如下所示: [键:1值:1] [键:2值:2] [键:3值:三] [键:4值:4] [键:5值:5]

但它是按以下顺序读的:三,一,四,二,五

知道为什么吗?? 或者甚至是另一种做for循环的方法,也许它的顺序是正确的


谢谢

NSDictionary
对象不保留顺序。您不应该期望按读取键的相同顺序枚举键

知道为什么吗


NSDictionary
是无序的。

如果顺序很重要,您应该在plist中创建一个数组,并从字典键之一访问它。

@Vasi:如果顺序很重要,请使用数组。您也不应该期望枚举顺序在任何情况下都是稳定的。