• 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: How to callback into a Obj-C object from C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to callback into a Obj-C object from C?


  • Subject: Re: How to callback into a Obj-C object from C?
  • From: Dan Wood <email@hidden>
  • Date: Thu, 15 Aug 2002 13:14:00 -0700

Just keep track of the "self" parameter so you can send a message back to the appropriate object.

For instance, in CURLHandle <http://curlhandle.sourceforge.net/>, the C callback invokes ObjC like this:



/*" Callback from reading a chunk of data. Since we pass "self" in as the "data pointer",
we can use that to get back into Objective C and do the work with the class.
"*/

size_t curlBodyFunction(void *ptr, size_t size, size_t nmemb, void *inSelf)
{
return [(CURLHandle *)inSelf curlWritePtr:ptr size:size number:nmemb message:BODY];
}





On Thursday, August 15, 2002, at 10:50 AM, Pete wrote:

I have a bunch of C code that I want to control printf statements and funnel back into a NSTextField. So how do I bridge and external C callback into an Obj-C object i.e. NSTextField object?

Pete
_______________________________________________
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.



--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/
_______________________________________________
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.

References: 
 >How to callback into a Obj-C object from C? (From: Pete <email@hidden>)

  • Prev by Date: Re: How to callback into a Obj-C object from C?
  • Next by Date: SIGBUS errors when dragging from the Finder to an NSTableView
  • Previous by thread: Re: How to callback into a Obj-C object from C?
  • Next by thread: PB question (2 targets, depending on shared code and each other)
  • Index(es):
    • Date
    • Thread