Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在排序时遇到问题...我需要对NSArray包含NSDictionaries. 作为订单键,我必须使用NSDictionary.
NSArray
NSDictionaries
NSDictionary
我正在阅读一些关于排序的内容NSArray,但我不清楚。你能帮帮我吗?
使用一个NSSortDescriptor和一个键路径。假设字典的键是key:
NSSortDescriptor
key
NSSortDescriptor *sd = [NSSortDescriptor sortDescriptorWithKey:@"key" ascending:YES]; NSArray *sorted = [array sortedArrayUsingDescriptors:[NSArray arrayWithObject:sd]];