• 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: 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.

  • Follow-Ups:
    • Re: Accessing objects from plain c code
      • From: Robert Tillyard <email@hidden>
References: 
 >Re: Accessing objects from plain c code (From: Robert Tillyard <email@hidden>)

  • Prev by Date: Setting the replace string in the Panther standard Find panel
  • Next by Date: Re: NSTextView data binding delay
  • Previous by thread: Re: Accessing objects from plain c code
  • Next by thread: Re: Accessing objects from plain c code
  • Index(es):
    • Date
    • Thread