Re: Intercepting messages
Re: Intercepting messages
- Subject: Re: Intercepting messages
- From: Ondra Cada <email@hidden>
- Date: Tue, 21 Mar 2006 16:17:49 +0100
Rob,
On 21.3.2006, at 11:31, Rob In der Maur wrote:
Thanks Joar, but is this the only viable alternative?
Of course not. Poseasclassing is just (probably) the most harmless
way of all the possible ones. You can manipulate the method dispatch
tables directly (which may be better than poseAsClassing, especially
if the target class has been used before your plugin comes to life).
You can use isa-swizzling (in this case, and presumed you really need
to intercept anything, probably the best way--but beware clashes with
Apple's KVO isa-swizzling). There's also potential proxying by
intercepting alloc and putting your proxy there and the original
object elsewhere (ugly, difficult, and hardly ever worth the effort),
or even truly hard-core techniques like patching objc_send :) And I
bet I still forgot a technique or two :)
Nevertheless, intercepting others' messages is never easy, all ways
are pretty prone to generate strange and hard-to-find errors, and
actually I would not recommend any of them to beginners (well you may
be an experienced programmer of course, but since you did mention
NSNotifications which have completely nothing to do with this hints
otherwise).
Perhaps it would help if you let us know what exactly is the goal?
Quite probably there would be an easier solution. A category might
help perhaps. Or, if the task is just to learn what happens in an
undocumented framework/application (happens time to time even if
someone is not cracking a licence code :))), gdb is your best friend.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden