Details about NSCharacterSet and nscharacterset
NSCharacterSet
For string processing, it is often used in the IOS ecosystem and is an important component of errors:NSCharacterSet
. The following is a detailed explanation:
NSCharacterSet
And its variable versionNSMutableCharacterSet
Represents a group of Unicode characters in the object-oriented manner. It often worksNSString
AndNSScanner
Used in combination to filter, delete, or split different characters. To provide you with an intuitive impression of the characters, please referNSCharacterSet
Provided class methods:
1 alphanumericCharacterSet // All numbers and letters (uppercase and lowercase) 2 3 character // upper case 4 5 controlCharacterSet // control character 6 7 character // 0-9 digit 8 9 decomposableCharacterSet // can break down 10 11 illegalCharacterSet // invalid 12 13 letterCharacterSet // all letters 14 15 characters // lowercase letter 16 17 newlineCharacterSet // linefeed 18 19 nonBaseCharacterSet // non-base 20 21 punctuationCharacterSet // punctuation 22 23 symbolCharacterSet // symbol 24 25 characters // uppercase letter 26 27 whitespaceAndNewlineCharacterSet // space and linefeed 28 29 whitespaceCharacterSet // Space
View Code
Contrary to its name,NSCharacterSet
AndNSSet
All linksNo.
Although the underlying implementation is not the sameNSCharacterSet
In terms of conceptNSIndexSet
AlsoA bitSimilar.NSIndexSet
As mentioned earlier, it indicates an ordered, non-repeating, unsigned integer set. Unicode characters are similar to unsigned integers and correspond to some spelling expressions. Therefore,NSCharacterSet +lowercaseCharacterSet
Character Set with a range of 97 to 122NSIndexSet
Is equivalent.
Remove Spaces
NSString -stringByTrimmingCharactersInSet:
This method you need to keep in mind. It is often passed in:
NSCharacterSet + whitespaceCharacterSet (or + whitespaceAndNewlineCharacterSet)
To delete the white space at the beginning and end of the input string.
Note that this methodOnlyRemoveStartAndEndConsecutive characters in the specified character set. That is to say, if you want to remove extra spaces between words, please refer to the next step.