• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling an object from a C function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Calling an object from a C function (From: Gilbert Mackall <email@hidden>)
 >Re: Calling an object from a C function (From: David Duncan <email@hidden>)
 >Re: Calling an object from a C function (From: Charlie Dickman <email@hidden>)
 >Re: Calling an object from a C function (From: David Duncan <email@hidden>)
 >Re: Calling an object from a C function (From: Charlie Dickman <email@hidden>)
 >Re: Calling an object from a C function (From: Antonio Nunes <email@hidden>)
 >Re: Calling an object from a C function (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Best Way to Handle Properties?
  • Next by Date: Re: This document's file has been changed by another application?
  • Previous by thread: Re: Calling an object from a C function
  • Next by thread: Re: Calling an object from a C function
  • Index(es):
    • Date
    • Thread