3

私は奇妙な問題に直面しています。isEqualtoString メソッドを使用して比較したい UITextField と NSString があります。Strings に Ä、Ö、Ü などのドイツ語のウムラウテが含まれていない限り、すべて正常に機能しますが、含まれていると機能しなくなります。NSLog は、ウムラウト文字列を正しく提供します。

 NSLog([currentAnswer lowercaseString]);
 NSLog([[self.antwortTextField text]lowercaseString]);

if ([[currentAnswer lowercaseString] isEqualToString:[[self.antwortTextField text]lowercaseString]]) {......}

どういうわけか文字列をフォーマットする必要がありますか? この問題は私を狂気に駆り立てています!

4

1 に答える 1

4

次のような高度なNSString比較方法を使用できます。

- (NSComparisonResult)compare:(NSString *)aString
                      options:(NSStringCompareOptions)mask
                        range:(NSRange)range
                       locale:(id)locale

次に、詳細オプションを指定します。興味のある特定のオプション:

  • NSCaseInsensitiveSearch
  • NSDiacriticInsensitiveSearch
  • NSWidthInsensitiveSearch
于 2012-04-27T16:21:00.750 に答える