Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the fastest way to find the number of spaces in an NSString?

Tags:

cocoa

I have an NSString and I want to find the number of spaces in it. What's the fastest way?

like image 227
Boon Avatar asked Dec 21 '25 01:12

Boon


1 Answers

Perhaps not the fastest to execute, but the fastest to type up:

[[myString componentsSeparatedByString:@" "] count]-1
like image 53
Sergey Kalinichenko Avatar answered Dec 24 '25 10:12

Sergey Kalinichenko