Re: Call Cocoa from C++
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