gpt4 book ai didi

objective-c - 如何按字母顺序对 UITableView Sectioned 进行排序?

转载 作者:太空狗 更新时间:2023-10-30 03:59:44 25 4
gpt4 key购买 nike

我有一个包含 3 个类别的分段 UITableView。我正在使用这段代码:

NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];
NSDictionary *dictOne = [NSDictionary dictionaryWithObject:arrayOne forKey:@"Elements"];

对于每个类别。

如何按字母顺序对它们进行排序?我在这里阅读了一些答案,但没有发现任何问题。

如果我使用此答案中的代码 Method for sorting custom objects alphabetically in UITableView它不起作用。我有代码:

[listObjects addObject:dictOne];

如果我放

[listOfTitles sortUsingDescriptors:[NSArray arrayWithObject:titleSorter];

它不起作用。

感谢任何帮助

最佳答案

NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];

NSArray *sortedArray = [arrayOne sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];


NSDictionary *dictOne = [NSDictionary dictionaryWithObject:sortedArray forKey:@"Elements"];

关于objective-c - 如何按字母顺序对 UITableView Sectioned 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6844534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com