How do I check if a string contains another string in Objective-C?

前端 未结 23 2017

How can I check if a string (NSString) contains another smaller string?

I was hoping for something like:

NSString *string = @\"hello bla         


        
23条回答
  •  情深已故
    2020-11-22 15:23

    Here is a copy-and-paste function snippet:

    -(BOOL)Contains:(NSString *)StrSearchTerm on:(NSString *)StrText
    {
        return [StrText rangeOfString:StrSearchTerm 
            options:NSCaseInsensitiveSearch].location != NSNotFound;
    }
    

提交回复
热议问题