0

How can I get the values from dictionary order which I added. Or Is there any way get ordered dictionary the order should be which I added order.

[inputParams setObject:@"One" forKey:@"allTasksDeatils"];
[inputParams setObject:@"123" forKey:@"ORGID"]; 

Result is:

{
ORGID = 123;
allTasksDeatils = One;
}

I want in same format like first object is become first :

{
 allTasksDeatils = One;
 ORGID = 123;
}

please help me..thanks in advance

NaniBhai
  • 3
  • 3
  • Is it possible sort like same given order.. – NaniBhai Jun 02 '15 at 14:29
  • It sounds like what you want is more like an (ordered) array of pairs, not a dictionary. You could create a simple object that contains the two strings, and put those in an NSMutableArray. Or you could simply make an array of 2-item arrays. – Ben Zotto Jun 02 '15 at 16:05
  • Sorry I want dictionary of ordered values.. the order should be like which elements are added by first.. – NaniBhai Jun 03 '15 at 04:52
  • I understand what you want; a regular dictionary does not have this behavior, and neither do any of the standard Foundation collections. You could quite easily create a new object that wraps a dictionary and an array; as you add objects to the dictionary, also append the key to the array. Then you can query the dictionary directly, and you can also iterate through the ordered key list if you need to. – Ben Zotto Jun 03 '15 at 16:01

0 Answers0