"localizedStandardCompare" depends on the language preference of the iOS device -


nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"name" ascending:yes selector:@selector(localizedstandardcompare:)];  [fetchrequest setsortdescriptors:[nsarray arraywithobjects:sortdescriptor,nil]]; 

i working on app has list of names, names in Íslenska(icelandic) language. above code works fine if language selected apps in settings Íslenska(icelandic) sort descriptor fails if language other Íslenska(icelandic).

is there way resolve dependency problem?

this should create sortdescriptor compare strings using is_is locale.

nssortdescriptor* sortdescriptior =[[nssortdescriptor alloc] initwithkey:@"name" ascending:yes comparator:^(nsstring* str1, nsstring* str2) {     static nsstringcompareoptions comparisonoptions =     nscaseinsensitivesearch | nsnumericsearch |     nswidthinsensitivesearch | nsforcedorderingsearch;      return [str1 compare:str2 options:comparisonoptions range:nsmakerange(0, str1.length) locale:[nslocale localewithlocaleidentifier:@"is_is"]]; }]; 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -