Exercises

  1. Some of the functions that we implement in the PrefController class are provided as part of the NSWindowController class. Reimplement the PrefController class as a subclass of NSWindowController, removing any code possible.

  2. In our implementation of the GraphPaper application, the PrefController communicates directly with the GraphView object when the preferences are changed. This design violates encapsulation between the two class designs and limits the application to having a maximum of one GraphView object. A better design would be to have the GraphView object register to receive an NSDefaultsChangedNotification and use this as a signal to reread the values from the defaults database. The PrefController would then post an NSDefaultsChangedNotification when the default values changed. Implement this design.

  3. After you have completed the previous exercise, rewrite the GraphPaper application so that it uses the multiple-document architecture that we used with MathPaper.

  4. Implement Document Save and Document Load for the multiple-document version of GraphPaper that you developed in the previous exercise. Your GraphPaper “document” should include formulae to be graphed, as well as the current color-well settings.

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.