Re: Calling an object from a C function
Re: Calling an object from a C function
- Subject: Re: Calling an object from a C function
- From: Antonio Nunes <email@hidden>
- Date: Wed, 20 Aug 2008 12:23:43 +0100
On 20 Aug 2008, at 11:16, Ken Thomases wrote:
Well, you can try to achieve this result with the Objective-C
runtime. The better approach would be to have the C function be a
very simple wrapper around an Objective-C method (as you
illustrated) and then have that method invoke 'super' if necessary.
Gosh, there's nothing quite like keeping it simple, is there?! So
obvious once someone rubs your nose in it. :-)
To turn your suggestion into code, using the callback to jump straight
back into the object, passing in any info that the callback provided,
we could do something like:
void operator_Tj(CGPDFScannerRef scanner, void *info)
{
[(MyObject *)info operator_Tj_WithScanner:scanner];
}
or, more generically:
void myCallbackFunction(<some argument list>, void *myObject)
{
[(id)myObject myObjectMethodToHandleThisCallbackWithArg1:arg1
arg2:arg2 etc:etc];
}
Cool!
António
----------------------------------------------------
There is nothing as strong as real gentleness, and
there is nothing as gentle as real strength.
----------------------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden