开发者

Sort JSON NSDictionary for UITableView

I am using TouchJSON to retrieve info for my app and put it in a dictionary. 开发者_高级运维I would like to be able to sort it by values like difficulty and rating. How would I go about this? I have included my .m file. Thanks, enbr http://pastie.org/1091334


You can probably use NSSortDescriptor to sort the array of dictionaries with specified keys. So, for example, the following can sort the array by the key "ratings" in each dictionary:

NSSortDescriptor *ratingsSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"ratings" ascending:YES] autorelease];
rows = [rows sortedArrayUsingDescriptors:[NSArray arrayWithObject:ratingsSortDescriptor]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜