For example [request responseString]’s value sent by my servlet to my iphone application is “myinfo”. In my iphone application, I made a string like this:
NSString *str = @"myinfo";
then i have if else
if([responseString isEqualToString:str]){
NSLog(@"condition true");
}else{
NSLog(@"condition false");
}
in console its always showing “condition false”. Whats the problem? Isn’t isEqualToString is write method to check if strings are equal or not? Thanks in advance.
The
NSStringmethodisEqualToStringis the correct thing to use here. You can do a sanity check by adding a log to your method:Remember that
NSStrings are Case Sensitive, so the two strings must appear exactly the same.