objective c - How can I find whether an exact sub string is present or not in NSString -
how can find whether exact substring present or not in nsstring.
currently assume string "1000 * roomtemperature" , want check whether "roomtemperature" present or not.
["1000 * roomtemperature" rangeofstring:"roomtemperature"].location != nsnotfound give me true. if check ["1000 * roomtemperature" rangeofstring:"temperature"].location != nsnotfound. return me true.
my requirement false second scenario. please me out solution.
try using following code. return true if word exist , false if not exist
nsstring *str = @"1000 * roomtemperature"; nsarray *array = [str componentsseparatedbystring:@" "]; return [array containsobject:@"roomtemperature"];
Comments
Post a Comment