Re: Accessing objects from plain c code
Re: Accessing objects from plain c code
- Subject: Re: Accessing objects from plain c code
- From: Chris Ridd <email@hidden>
- Date: Fri, 16 Jan 2004 09:36:06 +0000
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
_______________________________________________
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.