Chapter 10. MathPaper and Cocoa’sDocument-Based Architecture

In this chapter and in Chapter 11 through Chapter 14, we are going to start over and build a new, more sophisticated calculator-like application called MathPaper . MathPaper will manage multiple windows, use fonts to convey information, and use interprocess communication to make a request to another (back end) program to do the actual calculation. In writing MathPaper, we will learn a lot more about Cocoa’s architecture for creating applications that handle documents in multiple windows.

The MathPaper Application

When we’re done, MathPaper will be a scratchpad mathematics application that looks like a text editor: it will display a little text window into which you can type mathematical expressions. The neat thing about MathPaper is that when you hit the Return key, the application will automatically calculate the value of the mathematical expression that you’ve typed and display the result. Figure 10-1 contains an example of MathPaper running with three windows open.

MathPaper window with mathematical expressions and results

Figure 10-1. MathPaper window with mathematical expressions and results

MathPaper can handle multiple windows: typing Command-N will give you another “piece” of “math paper.” In later chapters of this book, we’ll use part of MathPaper to graph equations as well. MathPaper has four main parts:

Document-based architecture

Cocoa’s powerful document-based architecture ...

Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.