Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find if char is in string in objective c

Tags:

objective-c

I looked all over the NSString class reference but I can't seem to find out if I have a string, what method can I use to check if a particular character is inside of the string.

For example, if my string is

NSString * string = "123.32"

if ([string hasString:@"."]) {
//do stuff

so I don't really care the index that it is at but whether it has it or not :-)

like image 833
Guillermo Alvarez Avatar asked Feb 22 '23 20:02

Guillermo Alvarez


1 Answers

You want rangeOfString: — so, for example, [string rangeOfString:@"."].location != NSNotFound.

like image 139
Chuck Avatar answered Mar 02 '23 16:03

Chuck