Monday, December 30, 2013

About NSDictionary sorting problem

Now I have a NSDictionary object, there are 300 elements, including key format is "Item #" (# 1 to 300 numbers). Since NSDictionary itself is out of order arranged according to the order read out the words, first sort allKeys array. Now my question is, how will the array [dict allKeys] obtained by the method according to the order I want arrangement (ie, according to Item 1 .... Item 300 in that order)
Reply:
NSMutableArray * tempArray = [NSMutableArray arrayWithArray: [myDict allKeys]]; [tempArray sortedArrayUsingSelector: @ selector (myComparison :)];
for (Foo * f in tempArray)
{
Value * val = [myDict objectForKey: f];
}
Reply:
Hello, for sortedArrayUsingSelector: myComparison @ selector (myComparison :) This way I do not quite understand, @ selector () inside what is? Trouble can explain it?

Reply:
reference to the second floor raistlinqjx reply:
Hello, for sortedArrayUsingSelector: @ selector (myComparison :) This way I do not quite understand, @ selector () inside myComparison what is? Trouble can explain it?

Your sorting method.
Reply:
The reply was deleted at the moderator 2011-04-11 10:40:42

No comments:

Post a Comment