Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
5 つの NSString があり、いずれかの文字列が同じかどうかを確認したい場合、[string isEqualToString:string2]各文字列をテストするために何度も使用するよりも高速な方法はありますか?
[string isEqualToString:string2]
文字列が 5 つしかない場合、おそらく 1 つずつ比較するよりも高速な方法はありません。
ただし、多数の文字列がある場合は、それらすべてを含む NSSet を作成し、-[containsObject:].
-[containsObject:]