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:
Open
MathPaper.pbprojin Project Builder and choose File → New File to create a new file calledRTF.h.Select Empty File in the New File Assistant pane and then click Next.
Enter “RTF.h” in the File Name field, make sure the MathPaper target is checked, and then click Finish.
Now enter the RTF class interface code, as provided in the previous section, into
RTF.h.Similarly, create another file called
RTF.mand insert the RTF class implementation code (also provided earlier) into it.If they aren’t there already, drag the
RTF.handRTF.mfiles 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.
Insert the following directive after the other
#importstatement near the top ofPaperController.m:#import "RTF.h"Insert the new appendRTFData: method declaration shown here into the existing NSTextView(MathPaper) category interface:
@interface NSTextView(MathPaper) ...
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