"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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

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