Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我用逗号分隔字符串。 首先我想检查是否包含逗号的字符串。在我的应用程序字符串如下所示:
NSString *str=@"1,2,3";
如何检查它是否包含逗号?
我通过使用以下代码解决了我的问题:
NSString *str=@"1,2,3"; NSArray *result=[str componentsSeparatedByString:@","]; if([result count]!=0) { NSLog(@"String contains comma"); }