Passing Obj-C method as callback to C function
Passing Obj-C method as callback to C function
- Subject: Passing Obj-C method as callback to C function
- From: email@hidden
- Date: Tue, 28 Oct 2003 14:58:41 -0000
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.
// header:
typedef int (*FUNC_ENUM_CALLBACK)(void *);
int EnumerateStuff( FUNC_ENUM_CALLBACK pCallback, void *pContext );
// lib source:
int EnumerateStuff( FUNC_ENUM_CALLBACK pCallback, void *pContext )
{
pCallback(pContext);
return 0;
}
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.
Is it possible to have the callback in the object itself.
Thanks
Alun Carp
Driver Development Team Leader
Data Encryption Systems Limited
_______________________________________________
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.