In Chapter 10, we showed how Cocoa’s multiple-document architecture takes care of many of the tasks involved in building a document-centric application, and we used a simple text editor as an example. Cocoa’s text-handling ability goes much further by supporting multiple fonts, various paragraph styles, embedded images, undo, drag-and-drop, and even spell checking. It can handle differences in text directionality and provides sophisticated typesetting capabilities, such as the ability to control kerning between characters.
In this chapter, we are going to examine the functionality of
and the other classes that compose the
text system. We’ll then dive into code and add the
following functionality, one step at a time, to a rich-text editor:
Enable the font menu
Work with attributed text
Register undo actions
Enable the text menu
Handle embedded images
Add a special feature that we’ll save for last
That’s a lot of ground to cover, so let’s get going!
system, which underlies the functionality we worked with in Chapter 10, consists of three API layers, as shown in
Figure 11-1. You can see the same
Model-View-Controller (MVC) paradigm
we’ve talked about previously in the design of the
text system. At the top layer is the
that provides the on-screen view of text.