• 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: Accessing objects from plain c code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Accessing objects from plain c code (From: Chris Ridd <email@hidden>)

  • Prev by Date: Solved: how to act when screen saver *really* stops
  • Next by Date: Re: How can I accept directory drops to my app icon?
  • Previous by thread: Re: Accessing objects from plain c code
  • Next by thread: Canceling a pop-up menu?
  • Index(es):
    • Date
    • Thread