Exercises

  1. Save a MathPaper file containing several calculations and then view the contents of the file in a Terminal window with the catcommand (or by using an editor). Look up and identify any RTF commands that we didn’t discuss in Chapter 12.

  2. Reimplement the methods dataRepresentationOfType: and loadDataRepresentation:ofType: so that the NSData object contains a serialized NSDictionary object that itself contains the window’s history and frame. The advantage of using an NSDictionary object for archiving is that it can give you both forward and backward compatibility with your saved documents — provided that later versions create the fields that the older versions expect to find.

  3. Reimplement the methods dataRepresentationOfType: and loadDataRepresentation:ofType: so that the NSData object contains an XML representation of the window’s history and frame. What are the advantages of using XML?

  4. Add a calculator-like keypad to MathPaper so that users can click buttons to create mathematical expressions in MathPaper’s key window. Implement this so that only one of these calculator-like keypads is needed for all of MathPaper — the new window should be a floating panel (utility window) that automatically inserts characters into the key window.

  5. For each MathPaper document window, add an auxiliary window that displays the contents of the history instance variable as it’s being filled with mathematical expressions and results. You will need to upgrade the MathDocument class and create a separate ...

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.