Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count of chars in NSString or NSMutableString?

I've tried this

NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString: myString];
[myCharSet count];

But get a warning that NSCharacterSet may not respond to count. This is for desktop apps and not iPhone, which I think the above code works with.

like image 270
4thSpace Avatar asked Sep 09 '25 15:09

4thSpace


1 Answers

I might be missing something here, but what's wrong with simply doing:

NSUInteger characterCount = [myString length];

To just get the number of characters in a string, I don't see any reason to mess around with NSCharacterSet.

like image 188
Matt Ball Avatar answered Sep 13 '25 10:09

Matt Ball