【发布时间】:2012-06-22 07:05:00
【问题描述】:
我将NSMutableArray 排序如下:
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:str_key ascending:bool_asc_desc] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [ads_printers_array sortedArrayUsingDescriptors:sortDescriptors];
问题是它区分大小写,我想让它不区分大小写。我怎样才能做到这一点?我尝试阅读文档并发现如下内容:
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:str_key ascending:bool_asc_desc selector: @selector(caseInsensitiveCompare)] autorelease];
但是,我不知道应该在选择器参数中添加什么。谢谢!
【问题讨论】:
-
谢谢大家,我使用的选择器方法是 (localizedCaseInsensitiveCompare:)。干杯!
-
完美,谢谢。 (Objective-C 中的 anything 是不是很简单......?!)
标签: objective-c cocoa nssortdescriptor