Re: Help Mixing Objective-C & Objective-C++
Re: Help Mixing Objective-C & Objective-C++
- Subject: Re: Help Mixing Objective-C & Objective-C++
- From: Charles Srstka <email@hidden>
- Date: Wed, 23 Feb 2011 19:34:01 -0600
On Feb 23, 2011, at 2:35 PM, James Bucanek wrote:
> It also occurred to me that if I'm careful, the Objective-C code doesn't really need any of the details of the instance variables in the Objective-C++ class:
>
> @interface MyCPPClass : NSObject
> {
> #ifdef __cplusplus
> @private
> SomeCPPClass *someCppObject;
> #endif
> }
> - (void)doSomething;
> @end
Not a good idea. In the 32-bit runtime, this might cause problems with subclassing due to the fragile base class problem. And if you are able to require the 64-bit runtime, then, as Sean pointed out, you don’t have to include instance variables in the header at all. Either way, there’s no reason to #ifdef out instance variables, unless you put a generic void pointer in an #else block to keep the size the same.
Charles_______________________________________________
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