开发者

UITableView sorting by rank

开发者 https://www.devze.com 2023-03-09 21:48 出处:网络
I have got an plist with an object it is a number开发者_C百科 with rank. I want to sort by the value of the float. From the biggest number to the lowest. And I dont know how to write the function.

I have got an plist with an object it is a number开发者_C百科 with rank. I want to sort by the value of the float. From the biggest number to the lowest. And I dont know how to write the function.

Thank you


You should sort the array you get from your plist by the rank

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"your rank key"
                                                                   ascending:YES];
    NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
    [yourArray sortedArrayUsingDescriptors:sortDescriptors];
    [sortDescriptor release];

Do it before you pass the array to the TableView

Good luck


Try this it might help you..

use NSSortDescriptor for sorting the values for acending or decending..

0

精彩评论

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

关注公众号