Friday, December 31, 2010

Case-insensitive NSSortDescriptor usage

I found this little gem today which was quite useful! If you are using a NSSortDescriptor to sort data using strings, you can make it case insensitive with the following:

sorter = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];

3 comments:

  1. Thank you! This is exactly what I'm looking for

    ReplyDelete
  2. Thanks for sharing tiny code of sorting method. I would like to if it works fine with Mobile Apps Development having huge data.

    ReplyDelete