I'm seeing a strange problem I'm trying to compare two stars in Swift The feedback received from is in the code given below, it is printing properly in "Outstanding" NSLog as "Error". But, when I compare to the bottom line, it fails, this error does not thrust the warning there. I do not know what I'm doing wrong. (Response, data, error) in the outputString: NSString = NSString (data: data, encoding: NSUTF8StringEncoding):
NSLog ("outputstring:% @", output string) if (output string == "error") {NSLog ("error")}}
NSString
class reference:Swift library reference -
string
:
If you are different, you will not be able to apply some action on one or the other.
You can do outputString == "Error"
to compare two string
because the comparison operator is present.
However, to compare two NSString
, you need to use the isEqualToString:
method. In your case, it should work like this: outputString.isEqualToString ("Error")
.
You can also compare string
to a NSString
with the ==
operator.
No comments:
Post a Comment