I have the function below that validates the return of another function (function searchPlaces that returns NSString). When I run it, it seems that the if clause is not bein
You should not comparing NSString
s with the ==
operator. The ==
operator performs reference equality on Objective-C object types: it only returns true if both operands refer to the exact same object. Even if two strings are copies of each other, ==
will return false if they refer to different instances.
You want to use value equality instead. You can compare strings using the -isEqualToString: method:
if ([novaurl isEqualToString:@"OK"]) {
...
}
You should use isEqualToString:
method of NSString to check for equality of strings. == operator does a pointer comparison and sometimes it will return NO although the contents of the strings are the same.