• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Deprecated APIs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deprecated APIs


  • Subject: Re: Deprecated APIs
  • From: Steve Christensen <email@hidden>
  • Date: Tue, 23 Feb 2010 20:57:57 -0800

On Feb 23, 2010, at 3:26 PM, Charles Srstka wrote:

On Feb 23, 2010, at 2:25 PM, Steve Christensen wrote:

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] ];
} ];
}

That code uses blocks, though, which implies that it will be compiled using a later version of Objective-C. Will that code really run on older versions of OS X?

The compile-time conditional assumes that you're building against the 10.6 SDK (or later). Obviously if you're going to support both cases, you'll need to use a compiler configuration that is compatible with all the OS versions you plan to support.


_______________________________________________

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


  • Follow-Ups:
    • Re: Deprecated APIs
      • From: Bill Bumgarner <email@hidden>
References: 
 >Deprecated APIs (From: charisse napeÿfffff1as <email@hidden>)
 >Re: Deprecated APIs (From: Steve Christensen <email@hidden>)
 >Re: Deprecated APIs (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Binding to a released object results in crash - how do find the observer?
  • Next by Date: Re: Core Data: Custom to-many relationship setter not being invoked
  • Previous by thread: Re: Deprecated APIs
  • Next by thread: Re: Deprecated APIs
  • Index(es):
    • Date
    • Thread