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

Re: Call Cocoa from C++


  • Subject: Re: Call Cocoa from C++
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 17 Dec 2009 11:35:52 -0800

On Dec 17, 2009, at 11:24 AM, Randall Meadows wrote:

> Just like that.  Put this into a .mm file, and it'll compile as Objective-C++.  You'll get a compiler warning that objcptr may not respond to updateText, which you can eliminate by casting objcptr to the appropriate class.

Or better, declare objcptr as the appropriate Obj-C type in the class declaration. This is problematic if your class header is #included by other C++ source files and you don't want to change them all to Obj-C++, but you can fix it with some #ifdefs:

#ifdef __OBJC__
#import "MyClass.h"
#else
struct MyClass;
#endif

...
	MyClass* objcptr;

—Jens_______________________________________________

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

References: 
 >Call Cocoa from C++ (From: David Blanton <email@hidden>)
 >Re: Call Cocoa from C++ (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: narraycontroller sort performance problems
  • Next by Date: Re: launching application after reboot
  • Previous by thread: Re: Call Cocoa from C++
  • Next by thread: Re: Call Cocoa from C++
  • Index(es):
    • Date
    • Thread