Check NSString Contains a comma (,) or not?

My string is comma separated.
First I want to check for a string containing a comma or not. In my application line as below:

NSString * str=@ "1,2,3"; 

How to check this comma or not?

+4
source share
1 answer

I solved my problem using the following code:

 NSString * str=@ "1,2,3"; NSArray *result=[str componentsSeparatedByString:@","]; if([result count]!=0) { NSLog(@"String contains comma"); } 
+1
source

Source: https://habr.com/ru/post/1444544/


All Articles