Iphone 在具有输入字符串的字符串中查找子字符串

Iphone 在具有输入字符串的字符串中查找子字符串,iphone,objective-c,nsstring,substring,Iphone,Objective C,Nsstring,Substring,若字符串是“测试组”,那个么如何找到“rou”是否是子字符串 通过使用此链接上的方法 仅给出完整单词like子字符串是否存在 类似于上面字符串中的“for”,但我想查找字符串中是否存在类似于“or”、“rou”的字符串 如何做到这一点 提前谢谢 编辑: 我的代码 - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { int count=0; arrayGroupName

若字符串是“测试组”,那个么如何找到“rou”是否是子字符串

通过使用此链接上的方法

仅给出完整单词like子字符串是否存在

类似于上面字符串中的“for”,但我想查找字符串中是否存在类似于“or”、“rou”的字符串

如何做到这一点

提前谢谢

编辑:

我的代码

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    int count=0;
    arrayGroupName=[[NSMutableArray alloc]init];
    if ([searchText isEqualToString:@""])
    {
        arrayGroupName=permArrayGroupName;
    }
    else
    {
        while (count!=[permArrayGroupName count])
        {


            if ([[[[permArrayGroupName objectAtIndex:count] objectGroupName]capitalizedString] rangeOfString:[searchText capitalizedString]].location == NSNotFound )
            {
                NSLog(@"string does not contain bla");
            }
            else
            {
                NSLog(@"found");
                [arrayGroupName addObject:[permArrayGroupName objectAtIndex:count]];
            }
            /*if ([[[[permArrayGroupName objectAtIndex:count] objectGroupName]capitalizedString] hasPrefix:[searchText capitalizedString]])
            {
                [arrayGroupName addObject:[permArrayGroupName objectAtIndex:count]];
            }*/
            count++;
        }
    }
    [tableGroupList reloadData];
} 
以下工作:

NSString *string=@"Testing for Group";

if ([string rangeOfString:@"rou"].location == NSNotFound) {
    NSLog(@"Not found");
}
else {
    NSLog(@"Found");
}

请出示实际代码<代码>范围字符串:不仅匹配完整的单词。@MatthiasBauch我的代码看起来不错。您应该检查实际比较的字符串,可能您的输入不是您所期望的。尝试将“未找到”NSLog替换为此
NSLog(@“字符串\”%@\”不包含\“%@\”、[[[permArrayGroupName objectAtIndex:count]objectGroupName]capitalizedString]、[searchText capitalizedString])查看实际使用的字符串。谢谢,我得到了答案,在我的代码中,我刚刚删除了大写的字符串,现在它可以正常工作了。