What is differnce between NSString and NSCharacter

2019-07-03 23:08发布

问题:

I studying NSCharacterset class. NSString and NSCharacterset look like similar class.

Who can explain difference between NSString and NSCharacterset?

When use NSCharacterset?

Thanks your help..

回答1:

An NSString object represents a string of ordered characters (text). An NSCharacterSet object represents a set of characters in no particular order. It is often much quicker to determine whether a character is a member of an NSCharacterSet than an NSString. You can't use an NSCharacterSet object to hold text, at least not in any sensible way, because it does not maintain any order of characters, its use is primarily for determining whether a character exists in a set of characters.