I am facing a weird problem. I have a UITextField and an NSString which I want to compare using the isEqualtoString method. As long as the Strings don't include German Umlaute such as Ä,Ö,Ü everything works fine but if they do it doesn't work anymore. NSLog gives out the Umlaute-Strings correctly.
NSLog([currentAnswer lowercaseString]);
NSLog([[self.antwortTextField text]lowercaseString]);
if ([[currentAnswer lowercaseString] isEqualToString:[[self.antwortTextField text]lowercaseString]]) {......}
Do I have to format the Strings somehow? This problem is driving me insane!
You can use an advanced NSString comparison method, such as:
- (NSComparisonResult)compare:(NSString *)aString
options:(NSStringCompareOptions)mask
range:(NSRange)range
locale:(id)locale
and then specify advanced options. Specific options you may be interested in:
NSCaseInsensitiveSearchNSDiacriticInsensitiveSearchNSWidthInsensitiveSearchIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With