Assembling the Text System
For many applications
that work with text, using NSTextView as the
frontend interface to the text provides a great deal of
functionality. This is by far the easiest way of working with the
text system: you only need to drop a text view into your interface
using Interface Builder, and you’re ready to go.
Using NSTextView’s APIs as the
sole means of working with the text system does not offer the
flexibility that can be achieved by assembling the individual
components manually. By starting with an
NSTextStorage object and adding layout managers,
text containers, and text views, document layouts can have multiple
columns and pages, have irregular areas of text, or present the same
text in two different layouts.
Before exploring the manually assembly of text components, consider these rules that tell you what you can and cannot do:
A text storage object may have one or more layout manager objects that it manages.
Each layout manager instance may manage one or more instances of
NSTextContainer.Each text container has exactly one text view associated with it.
By varying the structure of the network with respect to the first two rules, you can create the possibilities mentioned earlier.
Several methods in NSTextStorage,
NSLayoutManager, and
NSTextContainer facilitate assembly and management
of the object network.
-
NSTextStorage This class offers the following methods for managing its layout managers:
-
addLayoutManager: Adds the specified layout manager to the list of ...
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access