iPhone-为UITableView排序JSON NSDictionary

我正在使用TouchJSON来检索我的应用程序的信息,并将其放入字典中.我希望能够按难度和等级等值对它进行排序.我将如何处理?我已包含我的.m文件.
谢谢,enbr
http://pastie.org/1091334

解决方法:

您可能可以使用NSSortDescriptor对具有指定键的字典数组进行排序.因此,例如,以下代码可以按每个字典中的键“评级”对数组进行排序:

NSSortDescriptor *ratingsSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"ratings" ascending:YES] autorelease];
rows = [rows sortedArrayUsingDescriptors:[NSArray arrayWithObject:ratingsSortDescriptor]];
上一篇:作为程序员一定不要仅仅追求物质!电子版已问世


下一篇:Android开发最佳实践手册全网独一份,深入分析