-1

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 '.

2 Answers2

2

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 ");
}
0

try this:

    NSString *mainString = @"Your Data ";
    NSRange stringRange = [mainString rangeOfString:@"Data "
                           options:NSCaseInsensitiveSearch];
    NSString *subString = [mainString substringWithRange:stringRange];
    NSLog(@"substring :%@",subString);
amit_donga
  • 214
  • 1
  • 9