Re: Accessing objects from plain c code
Re: Accessing objects from plain c code
- Subject: Re: Accessing objects from plain c code
- From: Robert Tillyard <email@hidden>
- Date: Mon, 19 Jan 2004 00:58:08 +0000
On 16 Jan 2004, at 9:36 am, Chris Ridd wrote:
On 16/1/04 12:41 am, Robert Tillyard <email@hidden> wrote:
Do you have an example of the syntax used to call a method in
Objective-C from C please. I have a thread that is ftp-ing things from
a remote server and I would like to send the progress to the GUI so
that I can display a progress bar.
You get your C code to call a second C function in an Objective-C
module (ie
something in a .m file). That second C function can send messages to
objects
using the normal Objective-C syntax, because it is being compiled by an
Objective-C compiler. (BTW you don't call methods in Objective-C, you
send
them messages. That's an important distinction which you should be
able to
research using the list archives at cocoa.mamasam.com)
Something like this perhaps:
File1.c:
void *someobject;
...
Do_something_with(someobject);
...
File2.m
void Do_something_with(void *someobject)
{ // Change (id) to a cast to a more appropriate object
[(id)someobject somethingWithAnArgument: YES];
}
Cheers,
Chris
Thank you all for your help and examples, I have been able to add a
progress bar in my GUI Cocoa code from some network code in a .c file.
Regards, Rob.
_______________________________________________
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.