On Feb 23, 2010, at 2:09 AM, charisse napeÿfffff1as wrote:

I am not sure if this problem has already been submitted but how do I define two APIs, one that is supported from Leopard down and another that is only supported in Snow Leopard if I only have one binary for all OSes?

Below is a snippet of my code

[snip]

As others have already pointed out, it's your choice of whether or not to support a deprecated API method. When I decide to use OS version- specific API methods, I code as follows. The benefit is that, when you decide to support a minimum of 10.6, the code to support older OS versions is automatically stripped out at compile time.


#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
if (![panel respondsToSelector :@selector(beginSheetModalForWindow:completionHandler:)])
{
        // code to run on Leopard and earlier
        [panel beginSheetForDirectory: @"/Users/whatever/Pictures/"
                                 file: @"Untitled"
                       modalForWindow: mWindow
                        modalDelegate: self
didEndSelector: @selector(sheedDidEnd:returnCode:contextInfo:)
                          contextInfo: nil];
}
else
#endif
{
        // code to run on Snow Leopard or later
        [panel setDirectoryURL: @"/Users/whatever/Pictures/"];
        [panel setNameFieldStringValue:@"Untitled"];
        [panel beginSheetModalForWindow:mWindow
                      completionHandler:^(NSInteger returnCode) {
                                           [panel orderOut:self];
[self didEndPathSelectorSheet: returnCode filename: [ [panel URL] relativePath] ];
                                         } ];
}

_______________________________________________

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 arch...@mail-archive.com

Reply via email to