NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

NSDocument data:ofType implementation when using NSPrintInfo

Forums > macOS

After having read Hacking with macOS I'm trying to develop another NSDocument based application. In my document (subclassed from NSDocument) I have a few properties, an enum, an int and an array of objects. The objects implement the NSCoding protocol as described in the chapter. The application also implements printing and so I would like to save/load the NSPrintInfo property (printInfo on the NSDocument base class).

My question is how should I implement my data:ofType function override to accompish saving:

  • printInfo from NSDocument
  • My local int and enum
  • My local array of NSCoding implementing objects

In the book, NSKeyedArchiver is used but this just creates a single NSData object from a given single root object, whereas I have multiple objects to store. I could create a new data object to hold all the properties I wish to store, but then how should I refer back to the printInfo property on NSDocument?

1      

Hacking with Swift is sponsored by MadMachine

SPONSORED Want to explore your Swift skill outside of the Apple world? Join the MadMachine community and start to program microcontrollers in Swift.

Get it now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.