ios - How do I apply an array of NSSortDescriptors in a case insensitive way? -
because nshttpcookiestorage has awful limitations i'm implementing own , 1 of methods re-implement - (nsarray *)sortedcookiesusingdescriptors:(nsarray *)sortorder. gets array of nssortdescriptors , applies surprise, results tests seems indicate these sort descriptors applied in case insensitive fashion.
i couldn't find way apply nssortdescriptors in case insensitive way other setting selectors :@selector(caseinsensitivecompare:) since property selector read only, best managed this:
nsmutablearray *insensitivesortorder = [nsmutablearray array]; (nssortdescriptor* sorter in sortorder) { [insensitivesortorder addobject: [nssortdescriptor sortdescriptorwithkey: sorter.key ascending:sorter.ascending selector:@selector(caseinsensitivecompare:)]]; } is implementation correct? there better way achieve this?
one thing worries me i'm ignoring comparator property of nssortdescriptor.
Comments
Post a Comment