You can do this in one line. For example, this counts the number of spaces:
NSUInteger numberOfOccurrences = [[yourString componentsSeparatedByString:@" "] count] - 1;
Related Contents:
- Load R package from character string
- Converting escaped UTF8 characters back to their original form
- If “a == b” is false when comparing two NSString objects
- How to get the number of characters in a string
- Remove last character from string. Swift language
- Replace substring of NSAttributedString with another NSAttributedString
- How does an underscore in front of a variable in a cocoa objective-c class work?
- Getting “command not found” error while comparing two strings in Bash
- What is the difference between a string and a byte string?
- Understanding NSString comparison
- How can I upload a photo to a server with the iPhone?
- Difference between text and varchar (character varying)
- How to compare strings in Bash
- Convert Int to String in Swift
- How many bytes does one Unicode character take?
- In Bash, how can I check if a string begins with some value?
- Sqlite convert string to date
- How can I split multiple joined words?
- Get string after character [duplicate]
- When do you make an underscore in front of an instance variable? [duplicate]
- How to split a string into substrings of a given length? [duplicate]
- how to convert csv to table in oracle
- `[super viewDidLoad]` convention
- How to generate a random string of a fixed length in Go?
- Formatting NSDate into particular styles for both year, month, day, and hour, minute, seconds
- Getting and removing the first character of a string
- What are best practices that you use when writing Objective-C and Cocoa? [closed]
- Is there a way to suppress warnings in Xcode?
- Open Source Cocoa/Cocoa-Touch POP3/SMTP library?
- How can I concatenate multiple optional strings in swift 3.0?
- Convert string to integer type in Go?
- swift How to remove optional String Character
- setValue:forUndefinedKey: this class is not key value coding-compliant for the key [duplicate]
- Bash: Split string into character array
- How to generate all the permutations of a multiset?
- Changing the userAgent of NSURLConnection
- How to concatenate strings with padding in sqlite
- How to capitalize the first letter of a string in dart?
- NSArray Equivalent of Map
- Select rows from data.frame ending with a specific character string in R
- Swift, Strings and Memory Addresses
- []byte(string) vs []byte(*string)
- Measuring the pixel width of a string
- How to create subscript characters that’s not in Unicode in iOS
- Check whether a string contains a substring
- Find longest substring without repeating characters
- Ignoring certificate errors with NSURLConnection
- Replace one character with another in Bash
- Using MD5 hash on a string in cocoa? [duplicate]
- Getting The ASCII Value of a character in a C# string