是否可以按字母顺序对插入plist中的数据进行排序?如何?如果不是如何使用数组或任何其他方法点?它
先谢谢
答案 0 :(得分:1)
// read the file into a dictionary
NSString *path = [[NSBundle mainBundle] pathForResource:@"yourfile" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
// sort it
NSArray *sortedArray = [[myDict allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
// iterate and print results
for(NSString *key in sortedArray) {
NSLog(@"key=%@,value=%@", key, [dict objectForKey:key]);
}