• 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: Switching methods in private classes in Apple frameworks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switching methods in private classes in Apple frameworks


  • Subject: Re: Switching methods in private classes in Apple frameworks
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 11 Mar 2010 19:54:33 -0800

On 2010 Mar 11, at 18:00, Gideon King wrote:

> This is really cool...so I can replace a method without being a subclass or category.

I just need to chime in here, in case anyone missed it, to emphasize how *ALL-CAPS COOL* this is indeed.

In the ReadMe of Apple's MethodReplacement.zip sample code, it states "The trick is to define a category on the class whose method you want to replace."  We have just learned that this sentence is incorrect.  You do *not* need to define a category on the class whose method you want to replace.

As Gideon showed in his code, the first argument of class_getInstanceMethod() need *not* be self, and therefore you can replace any method in *any* class, even a private one that's unknown to the SDK, with any other method in *any class*, even a different class.

This makes Method Replacement much more powerful in debugging, and even patching bugs in Cocoa.

I just sent Apple a "wasn't helpful" gram on that ReadMe.

Thanks, Gideon.  I hope you've found out who's sending that notification releasing your moc :)

_______________________________________________

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: Switching methods in private classes in Apple frameworks
      • From: Gideon King <email@hidden>
References: 
 >How to debug this error on closing a document? (From: Gideon King <email@hidden>)
 >Re: How to debug this error on closing a document? (From: Kyle Sluder <email@hidden>)
 >Re: How to debug this error on closing a document? (From: Gideon King <email@hidden>)
 >Re: How to debug this error on closing a document? (From: Jerry Krinock <email@hidden>)
 >Switching methods in private classes in Apple frameworks (From: Gideon King <email@hidden>)
 >Re: Switching methods in private classes in Apple frameworks (From: Greg Parker <email@hidden>)
 >Re: Switching methods in private classes in Apple frameworks (From: Gideon King <email@hidden>)

  • Prev by Date: Use of KVC Array operators
  • Next by Date: Re: NSTableView _dataSourceValueForColumn:row: failure
  • Previous by thread: Re: Switching methods in private classes in Apple frameworks
  • Next by thread: Re: Switching methods in private classes in Apple frameworks
  • Index(es):
    • Date
    • Thread