On Dec 17, 2009, at 12:16 PM, David Blanton wrote:

> The question:
> 
> How / Can I store a pointer to an obj-c object in a C++ class and then send 
> messages to the obj-c object from C++?
> 
> Somethng like:
> 
> class MyClass
> {     
> public:
>       void* objcptr; // ptr to my obj-c object
>       void CallOBJC(void);
> }
> 
> MyClass::CallOBJC()
> {
>       [objcptr updateText];
> }

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.

I've done this very thing, but from plain ol' C.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to