O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Challenge: Persist Page Setup

The configuration changes made in the Page Setup sheet are document-specific. Cocoa does not provide any automatic support for persisting these settings, however. It is your responsibility to save and load them. Fortunately, NSPrintInfo (stored in the document’s printInfo property) conforms to NSCoding. Modify the Document class to archive the printInfo along with the employees array when saving, and vice-versa when loading.

This is not quite as straightforward as it sounds. For one thing, the file format of rsmn files is simply an archived array. It makes no allowances for additional information. You will need to change the format. A popular pattern for this is to use a dictionary as the top level object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required