• 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: Julian Barkway <email@hidden>
  • Date: Thu, 15 Aug 2002 21:58:33 +0200

On Thursday, August 15, 2002, at 07:50 pm, 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?

Well you could try something like:

void cFunc (NSTextField *textField)
{
char *cString;

sprintf (cString, "a string with %s", "some stuff");
printf (cString);
[textField setStringValue: [NSString stringWithCString: cString]];
}

(Programmed in Mail so might not work....)

It really is that easy - provided you aren't trying to access instance variables in your C function. That doesn't work.

--
Julian Barkway,
Zurich,
Switzerland.
_______________________________________________
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: PB question (2 targets, depending on shared code and each other)
  • Next by Date: Re: How to callback into a Obj-C object from C?
  • Previous by thread: How to callback into a Obj-C object from C?
  • Next by thread: Re: How to callback into a Obj-C object from C?
  • Index(es):
    • Date
    • Thread