Apple's documentation for NSPrintInfo states in part:
A shared NSPrintInfo object is automatically created for an application and is used by default for all printing jobs for that application.
The method sharedPrintInfo
returns the shared NSPrintInfo
. What's not explicitly stated is if you alter that object (e.g., by using setOrientation
), do said alterations "stick" with the shared object? I.e., is the object you get back a singleton or a fresh copy of the shared object?
One reason I ask is because I've seen in some of Apple's sample code where they explicitly call setSharedPrintInfo
at the end of a print job. Why do they do that if the shared object is a singleton?
Update
It seems I have to be clearer in my question. From Apple's documentation, there exists an instance of NSPrintInfo
that is the "shared" one. This "shared" instance is used by default when no NSPrintInfo
object is used explicitly in method calls. The method sharedPrintInfo
returns a pointer to this "shared" instance.
What's not clear is whether sharedPrintInfo
clones the "shared" instance and returns a pointer to that, or simply returns a pointer to the existing instance.
If cloned, then any call such as one to setOrientation
will affect the clone only. If I wanted to alter the orientation of the "shared" instance also, I would have to call setSharedPrintInfo
supplying the altered clone as an argument.
If not cloned, then it's not clear why Apple's sample code explicitly calls setSharedPrintInfo
because all method calls altering the state of the NSPrintInfoObject
returned by sharedPrintInfo
already affected the "shared" instance.