Re: How to callback into a Obj-C object from C?
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.