Im using an NSDictionary from a tutorial that i found, but I just had a quick question as to why it is being sorted alphabetically?
NSArray *array = [[NSArray alloc] initWithObjects:userName, nil];
NSArray *array2 = [[NSArray alloc] initWithObjects:@"Other Data", @"Second Entry", nil];
NSDictionary *temp =[[NSDictionary alloc] initWithObjectsAndKeys:array, @"Name", array2, @"A",nil];
self.sortedKeys =[[temp allKeys] sortedArrayUsingSelector:@selector(compare:)];
Thanks for the help.
Because you are sorting them alphabetically?
self.sortedKeys =[[temp allKeys] sortedArrayUsingSelector:@selector(compare:)];
Note that a dictionary's keys are inherently unordered. If you need some kind of sort order applied to the keys, you'll need to maintain it yourself separately from the dictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With