On Jul 5, 2008, at 5:08 AM, Keith Blount wrote:

I am currently overhauling printing in my application. I have a page layout accessory view and I now also want to add a print panel accessory view. My app runs on both Tiger and Leopard. - setAccessoryView: works on both Tiger and Leopard, for adding an accessory view to both NSPageLayout and NSPrintPanel. However, in both cases, -setAccessoryView: was (rather frustratingly in this case, I feel, as it worked fine) informally deprecated on Leopard. Instead, we are advised to use -addAccessoryViewController:, which uses an NSViewController. But the NSViewController class doesn't even exist on Tiger, so subclassing it and having it in the project will cause the app not to run on Tiger at all. I don't want a different build for both Tiger and Leopard, of course, So, what is the proper way of handling this? The path of least resistance is to use -setAccessoryView: and hope it doesn't get formally deprecated on Snow Leopard, and continues to work for a while despite its deprecated status. But that obviously isn't the *best* (or correct) way of doing things. Any alternative is going to be more complicated and involve having separate elements of code for Tiger and Leopard, which isn't ideal, but I would love to know the established way of handling this.


To handle a case like this, you are going to have to create a bundle that you link against the 10.5 SDK and only load there. This bundle will contain your NSViewController subclass and allow you to conditionally call -setAccessoryView: on 10.4 and - addAccessoryViewController: on 10.5. This is a general pattern that you can use when you want to provide alternate functionality where it is a requirement to subclass and that subclass only exists on a newer version of the OS.

As for -setAccessoryView: (and other deprecated methods) there really isn't a case of formal vs informal deprecation - deprecated is deprecated. In this particular case, using -setAccessoryView: for example will disable the inline print preview, so you'll want to avoid calling it on 10.5.
--
David Duncan
Apple DTS Animation and Printing
[EMAIL PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to