现在我有一个NSDictionary的对象,内有300个元素,其中key的格式是“Item #”(#为1~300的数字)。由于NSDictionary自身是乱序排列的,要按顺序读出的话,要先对allKeys数组排序。现在我的问题是,该如何将[dict allKeys]方法得到的的数组按我想要的顺序排列(即按照Item 1….Item 300 这样的顺序) |
|
20分 |
NSMutableArray* tempArray = [NSMutableArray arrayWithArray:[myDict allKeys]]; [tempArray sortedArrayUsingSelector:@selector(myComparison:)];
for (Foo* f in tempArray) { Value* val = [myDict objectForKey:f]; } |
你好,对于sortedArrayUsingSelector:@selector(myComparison:)这个方法我还不是很理解,@selector()内的myComparison是什么?可以麻烦再解释一下吗?
|
|
20分 |
你的排序方法。 |