gpt4 book ai didi

cocoa - NSArray排序:

转载 作者:行者123 更新时间:2023-12-03 17:58:53 26 4
gpt4 key购买 nike

我想对这个 NSString 数组进行排序:

"Page_1",
"Page_10",
"Page_11",
"Page_12",
"Page_13",
"Page_14",
"Page_15",
"Page_16",
"Page_17",
"Page_18",
"Page_19",
"Page_2",
"Page_20",
"Page_21",
"Page_22",
"Page_23",
"Page_24",
"Page_3",
"Page_4",
"Page_5",
"Page_6",
"Page_7",
"Page_8",
"Page_9"

但我一直收到此代码的错误:

NSArray* sortedArray = [currentViews sortedArrayUsingSelector:@selector(compare:NSNumericSearch)];

甚至不确定这是否是正确的方法,查看 NSArray 文档让我觉得我应该使用比较器。任何帮助,将不胜感激。

最佳答案

您确实需要一个比较器,因为您尝试排序的实际上是一个 NSString,而不是 NSNumber。

关于cocoa - NSArray排序:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9588840/

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