查询NSString字符串中字符的位置及length

    NSString *tmpStr = [[NSStringalloc] initWithString:@"abcdefg"];

    NSRange range;

    range = [tmpStr rangeOfString:@"a"];

    if (range.location != NSNotFound) {

       NSLog(@"found at location = %d, length = %d",range.location,range.length);

    }else{

       NSLog(@"Not Found");

    }


你可能感兴趣的:(查询NSString字符串中字符的位置及length)