• 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
How to choose different implementations of an object method at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to choose different implementations of an object method at runtime?


  • Subject: How to choose different implementations of an object method at runtime?
  • From: Michael Crawford <email@hidden>
  • Date: Mon, 20 Jan 2014 15:27:49 -0500

I'm working on a Mac OS X product that currently runs on 10.6 through to 10.9.  This product includes an NSColor category method named CGColor, which is patterned after the iOS UIColor interface and returns a CGColorRef.

@interface NSColor (CGColor)
- (CGColorRef)CGColor CF_RETURNS_RETAINED;
@end

As I'm sure you are aware, 10.8 now defines a method that does the same thing using the same name.  I'd like to make it so that calling code doesn't have to distinguish between these two methods but invokes the correct one based on which version of the runtime is present.  What is the best approach to solving this problem?

I also realize that the 10.8 version returns an autoreleased object whereas the version written a couple of years ago must have the resulting reference freed by the caller.  I'm not sure how Apple pulls that off with a CF reference but I'd love to have a solution for that as well.

Discussion?

-Michael
_______________________________________________

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: How to choose different implementations of an object method at runtime?
      • From: Jens Alfke <email@hidden>
    • Re: How to choose different implementations of an object method at runtime?
      • From: Ken Thomases <email@hidden>
    • Re: How to choose different implementations of an object method at runtime?
      • From: Greg Parker <email@hidden>
  • Prev by Date: Re: Auto Layout with NSSplitView, NSScrollView
  • Next by Date: Re: iOS 7 downloadable fonts
  • Previous by thread: Re: UITableViewCell highlight color in iOS 7 (Settings app)
  • Next by thread: Re: How to choose different implementations of an object method at runtime?
  • Index(es):
    • Date
    • Thread