iphone - IOS isEqualToString Not Working -


the following example program outputs same, program not work correctly.

nsdirectoryenumerator *directoryenumerator = [[nsfilemanager defaultmanager]                                    enumeratoratpath:kdocdir];  (nsstring *pathi in directoryenumerator) {    nsstring *filename_manager = [pathi lastpathcomponent];    nslog(@"filename_manager = %@",filename_manager);     artist *name_databse =  [self.fetchedresultscontroller                                objectatindexpath:indexpath];    nslog(@"name_databse     = %@",name_databse.name);       if ([filename_manager isequaltostring:name_databse.name]) {        nslog(@"same name");    }else{        nslog(@"different name");    }  } 

outputs:

2013-04-25 15:37:43.256 player[36436:907] filename_manager = alizée - mèxico - final j'en 2013-04-25 15:37:43.272 player[36436:907] name_databse     = alizée - mèxico - final j'en 2013-04-25 15:37:44.107 player[36436:907] different name 

does not work correctly when special characters in names. why happening? ...

have same problem here:

nspredicate *predicate = [nspredicate predicatewithformat:@"name == %@",[pathi lastpathcomponent]]; 

how make edit here?

the documentation isequaltostring: suggests might have problem:

the comparison uses canonical representation of strings, particular string length of string plus unicode characters make string. when method compares 2 strings, if individual unicodes same, strings equal, regardless of backing store. “literal” when applied string comparison means various unicode decomposition rules not applied , unicode characters individually compared. so, instance, “Ö” represented composed character sequence “o” , umlaut not compare equal “Ö” represented 1 unicode character.

try using (nsorderedsame == [string1 localizedcompare:string2])

also, if haven't already, apple sample code 'international mountains' deals numerous localization issues.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -