天天看點

iOS 怎樣判斷兩個字元串是否相等

例1:

NSString *string = @"one";

NSString *stringTwo= @"two";

 BOOL isResult = [string compare:stringTwo];

 NSLog(@"=========%d",isResult);

0相等,-1不相等

例2:

字元串相等用方法isEqualToString

if([string isEqualToString:stringTwo])

{

     //相等

}