You see this because NSString is a cluster of classes. For more information, see Apple docs and here for a note specifically for the NSString subclass. Basically, NSString is an abstract class without a method of storing characters, and the various methods -initWith ... return different concrete subclasses of NSString based on the initialization method. Usually when you use NSString, it is completely transparent. However, if you want to subclass NSString, you should at least implement the basic methods (-length and -characterAtIndex :) plus any init methods that you want to have (plus, obviously, have a way to store string characters).
If you just want to add functionality to NSString, subclasses are usually not needed. First, you should check if a category or function that runs on NSString or a class method that contains NSString works better. For example, see RegexKit or Google Toolbox for Mac , both of which implement regex support using a category in NSString.
Boaz stuller
source share