< Previous PageNext Page > Hide TOC

Creating Text Storage

As an abstract class of a class cluster, allocating and initializing an NSTextStorage object in Objective-C actually produces an instance of a private subclass. You can use any NSAttributedString or NSMutableAttributedString initialization method to create an NSTextStorage object. To create an NSTextStorage in Java, use one if its constructors.

Having created the text storage object, you add NSLayoutManager objects to the text storage using addLayoutManager:. A single text storage object can have multiple layout managers (which is why this method name begins with “add” rather than “set”).

Creating a text storage object in this way and adding a layout manager is part of the process of assembling the text system programmatically, which is described in more detail in “Assembling the Text System by Hand.” You can also create an NSTextView object and let it assemble the text system automatically, in which case the text view creates (and later deallocates) the text storage object. For more information, see “Creating a Text View Programmatically.”



< Previous PageNext Page > Hide TOC


© 1997, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-08-11)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.