I wanted to search for a string: @"Data "
(including the space at the end) in the string (NSString *info)
. What should I do?
The string that is being searched has a space. Instead of @'data', I'm trying to find @'data '.
I wanted to search for a string: @"Data "
(including the space at the end) in the string (NSString *info)
. What should I do?
The string that is being searched has a space. Instead of @'data', I'm trying to find @'data '.
I don't know if i understand wich you want to do. But if you want to check if string contains in another string you need to do this:
NSString *yourString = @"Data your string";
if ([yourString rangeOfString:@"Data "].location == NSNotFound) {
NSLog(@"not contains Data ");
} else {
NSLog(@"contains Data ");
}
try this:
NSString *mainString = @"Your Data ";
NSRange stringRange = [mainString rangeOfString:@"Data "
options:NSCaseInsensitiveSearch];
NSString *subString = [mainString substringWithRange:stringRange];
NSLog(@"substring :%@",subString);