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.pbproj
in 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.m
and insert the RTF class implementation code (also provided earlier) into it.If they aren’t there already, drag the
RTF.h
andRTF.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.
Insert the following directive after the other
#import
statement 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) ...
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.