Function Pointers

  • I'm trying to interface with some c code that requires me to pass a
    function pointer.  I was wondering if its possible to pass a specific
    objects instance of a function.  For example:

    a->p_func= myObjCObject->stringValue or something like that.  I'd very
    much like to avoid writing a wrapper c function just to do
    [myObjCObject stringValue] since it will probably require me to write a
    lookup table etc etc.

    Thanks in advance,

    Francisco
  • > I'm trying to interface with some c code that requires me to pass a
    > function pointer.  I was wondering if its possible to pass a specific
    > objects instance of a function.

    No. If the API allows you to pass in some data for your function via a void
    *, then you can use that to pass your object, along with a pointer to a
    static function which will cast the void * to your function pointer and call
    the appropriate method. If the API does not do this, it is poorly designed.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.killerbytes.com/
    (303) 665-7007 voice