如果它们不相等,如何比较两个字符串

时间:2022-05-30 11:30:07

How would I compare two strings if they are not equal?

如果它们不相等,我如何比较两个字符串?

2 个解决方案

#1


40  

Just use isEqualToString and put an ! before the whole expression, like so:

只需使用isEqualToString并放入!在整个表达之前,像这样:

if (![self.passwordField.text isEqualToString: self.confirmPasswordField.text])

#2


2  

Use the NSString compare method (or one of the more detailed variations).

使用NSString比较方法(或更详细的变体之一)。

#1


40  

Just use isEqualToString and put an ! before the whole expression, like so:

只需使用isEqualToString并放入!在整个表达之前,像这样:

if (![self.passwordField.text isEqualToString: self.confirmPasswordField.text])

#2


2  

Use the NSString compare method (or one of the more detailed variations).

使用NSString比较方法(或更详细的变体之一)。