Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
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 ...
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