Re: Using deprecated methods
Re: Using deprecated methods
- Subject: Re: Using deprecated methods
- From: Keith Blount <email@hidden>
- Date: Sat, 5 Jul 2008 05:47:14 -0700 (PDT)
Hi,
Thanks for your reply. My project is set up just as you suggest and in fact I do use checks to see whether selectors are available and use the newer methods or older methods where appropriate where I can. But in the case I was talking about, there is a whole class that is unavailable - NSViewController. So, to use the new method (-addAccessoryController:) I would first need to create a subclass of NSViewController and include this subclass in the project. But given that the superclass (NSViewController) would not be available on Tiger, this would cause it to stall on Tiger. So I would need some way not only of checking for a particular method, but also of ignoring a whole class/subclass on the Tiger version... Moreover, the .nib file holding the accessory view would need to be connected up differently depending on whether it was using an NSViewController or not, meaning that there would probably need to be two different .nibs - identical in looks but
different in connections, one of which was ignored on Tiger, the other ignored on Leopard...
Hope that makes sense.
All the best,
Keith
----- Original Message ----
From: Jean-Daniel Dupas <email@hidden>
To: Keith Blount <email@hidden>
Cc: email@hidden
Sent: Saturday, July 5, 2008 1:26:17 PM
Subject: Re: Using deprecated methods
Le 5 juil. 08 à 14:08, Keith Blount a écrit :
> Hi,
>
> Something that has bothered me for ages in Cocoa, but which I've
> always put to one side, is how to handle certain deprecated methods
> when supporting more than one OS. In some instances it's as simple
> as checking at runtime which OS is being used and using the
> appropriate method accordingly, but I'm wondering here about the
> trickier instances. For instance:
>
> 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.
What make you think so ? You cna perfectly use 10.5 only symbol and
target 10.4 as long as you check that this symbol exist before your
use it.
if (MyLeopardOnlyFunction)
MyLeopardOnlyFunction(foo, bar, other);
You just have to be sure that your properly configure your project,
that is set SDK to th emax target version( 10.5) and set deployment
target to the min version (10.4)
So you just have to do something like this:
if ([myPanel
respondsToSelector:@selector(addAccessoryViewController:)] ) {
// go the nsviewcontroller way
} else {
// use the old way
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden