Re: howto mix objc/c++ in a nice way?
Re: howto mix objc/c++ in a nice way?
- Subject: Re: howto mix objc/c++ in a nice way?
- From: Simon Strandgaard <email@hidden>
- Date: Thu, 10 Nov 2005 21:21:11 +0100
On 11/10/05, Simon Strandgaard <email@hidden> wrote:
> On 11/10/05, Simon Strandgaard <email@hidden> wrote:
> > How to let B.test() access A's internals, without
> > using (void*) and reinterpret_cast?
>
> I should add that the header file is used in objc projects, so
> its not an option for me to change to objc++ mode for all the
> files that includes it.
>
> Any ideas?
Derrick Bass helped me out. Thanks.
The solution was to use (struct AInner*) in the header file,
and (AInner*) in the implementation file. See code below.
--
Simon Strandgaard
// in .h file
struct AInner;
@interface A : NSObject {
struct AInner* _inner;
}
-(id)init;
-(struct AInner*)inner;
@end
@interface B : NSObject {
}
+(void)test:(A*)a;
@end
// in .mm file
class AInner {
public:
int _value;
};
@implementation A
-(id)init {
_inner = new AInner;
_inner->_value = 42;
return self;
}
-(AInner*)inner {
return _inner;
}
@end // A
// in same .mm file
@implementation B
+(void)test:(A*)a {
AInner* inner = [a inner];
printf("the value is %i.", inner->_value);
}
@end // B
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden