Creating a Subclass of NSTextStorage

NSTextStorage isn’t a fully concrete class; rather, it is the abstract superclass of a class cluster. It defines the storage for its NSLayoutManager objects and implements some methods, but doesn’t provide the primitive attributed string methods to subclasses. A subclass must define the storage for its attributed string, typically as an instance variable of type NSMutableAttributedString, override init and define its own initialization methods, and implement the primitive methods of both NSAttributedString and NSMutableAttributedString. The primitive methods are:

Beyond these requirements, if a subclass overrides or adds any methods that change its characters or attributes directly, those methods must invoke edited:range:changeInLength: after performing the change in order to keep the change-tracking information up to date. See the method description for more information.