Integrating Our RTF Class into MathPaper

Now that we have defined the RTF class, let’s integrate it into the MathPaper application to get the promised fonts and formatting:

  1. Open MathPaper.pbproj in Project Builder and choose File New File to create a new file called RTF.h.

  2. Select Empty File in the New File Assistant pane and then click Next.

  3. Enter “RTF.h” in the File Name field, make sure the MathPaper target is checked, and then click Finish.

  4. Now enter the RTF class interface code, as provided in the previous section, into RTF.h.

  5. Similarly, create another file called RTF.m and insert the RTF class implementation code (also provided earlier) into it.

  6. If they aren’t there already, drag the RTF.h and RTF.m files into the Classes group in PB’s Groups & Files pane.

Tip

Another way to perform the six steps presented in this section is to first create the RTF.h and RTF.m class files outside of PB, using another editor (e.g., TextEdit or GNU Emacs). Save these two files in the ~/MathPaper folder, and then drag their file icons from the Finder and drop them into the Classes group in PB’s Groups & Files pane.

Now that our new RTF class has been added to the project, we proceed to make the necessary changes in the PaperController class.

  1. Insert the following directive after the other #import statement near the top of PaperController.m:

                         #import "RTF.h"
  2. Insert the new appendRTFData: method declaration shown here into the existing NSTextView(MathPaper) category interface:

    @interface NSTextView(MathPaper) ...

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.