Re: Major Bug in Cocoa (With sample Code!!)
Re: Major Bug in Cocoa (With sample Code!!)
- Subject: Re: Major Bug in Cocoa (With sample Code!!)
- From: Greg Titus <email@hidden>
- Date: Sat, 4 Aug 2001 13:52:14 -0700
On Saturday, August 4, 2001, at 01:34 PM, Jens Baumeister wrote:
>
>
Here's a quick and dirty fix for your problem. Add a category like this:
[...]
>
If you change your call from invokeWithTarget to newInvokeWithTarget ,
>
the retain count will stay the same. Needless to say, this is not an
>
ideal solution and you should still report the bug to Apple.
>
>
Questio: Would it be possible to name the category method
>
invokeWithTarget and still somehow access the original invokeWithTarget
>
from within the category - the way a call to super works from within a
>
subclass?
>
>
That would make the whole thing more elegant, because you wouldn't need
>
to change the code outside the category.
You can do it by modifying the Obj-C runtime directly and replacing the
existing implementation pointer with your new implementation, saving the
old implementation pointer and calling it directly inside the new
implementation.
There are a couple bug fixes similar to yours in OmniFoundation which do
this - you can look at them for examples. OmniBase includes a function
OBReplaceMethodImplementationWithSelector() to do the switch (just
search for that function).
-Greg