如何在像这样的块内的[index]
处获取对象?这是为了得到它的第一个字母,并按字典顺序排序NSDictionaries数组。
NSArray *sortedArray;
sortedArray = [_photos sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
NSString *first = _photos[0][FLICKR_PHOTO_TITLE];
NSString *second = _photos[0][FLICKR_PHOTO_TITLE];
return [first compare:second];
}];
_photos = sortedArray;
答案 0 :(得分:2)
看来你有一系列词典。要对FLICKR_PHOTO_TITLE
键的值进行排序,请执行以下操作:
_photos = [_photos sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *a, NSDictionary *b) {
NSString *first = a[FLICKR_PHOTO_TITLE];
NSString *second = b[FLICKR_PHOTO_TITLE];
return [first compare:second];
}];