views:

211

answers:

1

i create a array from a NSDictionary object:

 NSarray *myarray=[dictionary allValues];

however the return array object at index is not according to the dictionary, for instance the first object in dictionary was "title", but in my array it returned contact number, why this happended and how to prevent?

also when i set the object to my Dictionary it mess up the queue for instance:

[item setObject:@"title" forKey:@"title"];
[item setObject:@"1997" forKey:@"year"];
[item setObject:@"history" forKey:@"summary"];

but when i printed out this dictionary in console, the first object was become history, second become year, and last was title,how and why it could happen?am i miss anything thing i should now about NSDictionay, have anybody meet this problem before?

A: 

NSDictionary does not maintain order. The NSArray is ordered, but its data comes from the un-ordered dictionary.

See also: http://stackoverflow.com/questions/376090/nsdictionary-with-ordered-keys

diciu