• 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: Creating the app menu from scratch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating the app menu from scratch


  • Subject: Re: Creating the app menu from scratch
  • From: Jeff Johnson <email@hidden>
  • Date: Mon, 14 Jul 2008 10:58:49 -0500

On Jul 14, 2008, at 3:16 AM, Bill Bumgarner wrote:

On Jul 13, 2008, at 11:35 PM, Jeff Johnson wrote:

On the other hand, the function method_exchangeImplementations() just became public API in Leopard, so I don't see how that can break anytime soon. It's not much different than subclassing or 'categorizing'.

Correct. However, it is what you are using method_exchangeImplementations() for that is problematic. Namely, you are editing the method tables for an Apple supplied class. This is unsupported and may be problematic for any number of reasons -- KVO, IMP caching, internal implementation details, etc...


It is quite a bit different than either subclassing or using categories.

For subclassing, you override behavior and, if you are doing it right, don't break encapsulation -- don't access your super's instance variables directly and do use API to manipulate super's state (unless, of course, super is actually a class of your own design -- then it is all fair game, but you should still consider carefully how the super/sub relationship should be work).

For categories, all is well until the moment you override an existing method in a class other than your own. At that point, you are asking for a world of maintenance headaches and a whole lot of fun debugging stuff.

b.bum


I can't imagine much use for method_exchangeImplementations() with my own classes, because I can write the implementations myself. You certainly need to be careful, but my example seemed pretty innocuous. Calling at the beginning of main() should avoid IMP caching issues, should it not?

As I said, I was just doing a proof of concept. I haven't shipped any apps with that code, though I know plenty of developers who have shipped much 'worse'. Even published API sometimes break, so development always involves the assessment of risk and reward, and as far as I know, Apple provides no official support for developers apart from paid DTS incidents.

-Jeff

_______________________________________________

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: Creating the app menu from scratch
      • From: Bill Bumgarner <email@hidden>
References: 
 >Creating the app menu from scratch (From: "Jim Crafton" <email@hidden>)
 >Re: Creating the app menu from scratch (From: Jeff Johnson <email@hidden>)
 >Re: Creating the app menu from scratch (From: "Jim Crafton" <email@hidden>)
 >Re: Creating the app menu from scratch (From: Bill Bumgarner <email@hidden>)
 >Re: Creating the app menu from scratch (From: Jeff Johnson <email@hidden>)
 >Re: Creating the app menu from scratch (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: KVO notifications and threads
  • Next by Date: Re: PDFDocument Subclass and Undo Manager Redux
  • Previous by thread: Re: Creating the app menu from scratch
  • Next by thread: Re: Creating the app menu from scratch
  • Index(es):
    • Date
    • Thread