• 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: Cocoa Classes from C++?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Classes from C++?


  • Subject: Re: Cocoa Classes from C++?
  • From: Andrew Farmer <email@hidden>
  • Date: Tue, 27 May 2008 16:24:01 -0700

On 27 May 08, at 16:12, J. Todd Slack wrote:
1. I wish to create an NSStatusItem. I have ObjC Code to do so, but how can I do this in C++?

You can't. Cocoa is a Objective-C framework, and you'll need to write Objective-C code to use it effectively.


2. Can anyone point me to a reference of using Apple's Frameworks with C++ rather than ObjC?

3. How does one use a .C or .CPP file and call functionality in a .M?

You have three options, basically.

1. Write C glue functions in your ObjC source files. The ABI for C functions is unchanged in ObjC (unlike C++), so you can freely call these from C, and can call them from C++ with an extern "C" declaration.

2. Use Objective-C++, as Nick Zitzmann suggested. It's a ugly hybrid of ObjC and C++ - it'll let you use both languages in one source file, but don't expect anything really creative (like C++ objects as member variables of an ObjC object) to work quite correctly.

3. Use the Objective-C objc_* runtime functions. I wouldn't recommend this route.
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa Classes from C++?
      • From: Scott Ribe <email@hidden>
    • Re: Cocoa Classes from C++?
      • From: Jens Alfke <email@hidden>
References: 
 >Cocoa Classes from C++? (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: Cocoa Classes from C++?
  • Next by Date: Re: Date compiled?
  • Previous by thread: Re: Cocoa Classes from C++?
  • Next by thread: Re: Cocoa Classes from C++?
  • Index(es):
    • Date
    • Thread