Re: Passing Obj-C method as callback to C function
Re: Passing Obj-C method as callback to C function
- Subject: Re: Passing Obj-C method as callback to C function
- From: "Alastair J.Houghton" <email@hidden>
- Date: Tue, 28 Oct 2003 15:12:48 +0000
On Tuesday, October 28, 2003, at 02:58 pm, email@hidden wrote:
Hi all,
I have a library written in C which implements a function to provide
background notification of events.
Is it possible to pass an Obj-C object method
pointer/selector/whatever to
my C function to allow the library to perform it's callback.
No. From what I remember, methods take two hidden parameters, so the
single void * isn't enough. (Even if it was, it'd be a hack.)
What I currently have is a C function implemented outside the Obj-C
class
which receives a pointer to the Obj-C object as the context pointer,
it uses
this pointer to enable access to the object methods for handling the
callback.
This is the right way to do it.
Is it possible to have the callback in the object itself.
Only in as much as you can write your static function declaration and
definition inside the @implementation.
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.