Re: Help Mixing Objective-C & Objective-C++
Re: Help Mixing Objective-C & Objective-C++
- Subject: Re: Help Mixing Objective-C & Objective-C++
- From: Andreas Grosam <email@hidden>
- Date: Thu, 24 Feb 2011 12:53:46 +0100
On Feb 24, 2011, at 10:43 AM, Gwynne Raskind wrote:
> You can use protocols alone to do object creation with a little runtime trickery. I'm quite fond of this small set of language "extensions":
>
> <http://code.google.com/p/libextobjc/>
I would really prefer that this "extension" below will work soon: ;)
=== File: MyClass.h - Note this is an Objective-C++ header!! *)
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
- (id) init;
@end
=== File: MyClass.mm
#import "MyClass.h"
#include "Foo.hpp" // C++ class definition
@interface MyClass ()
-(void) privateMethod;
@end
@implementation MyClass {
Foo* privateIvar; // <== ivar declaration where it belongs to (IMHO)
}
- (id) init {
self = [super init];
if (self != nil) {
privateIvar = new Foo();
}
return self;
}
- (void) dealloc {
delete privateIvar;
[super dealloc];
}
- (void) privateMethod {
}
@end
*) Using an Objective-C++ header file in an Objective-C module may require some additional ’extern "C"’ declarations.
Unfortunately, this doesn't compile yet. This would require that LLVM can be used for Objective-C++ modules and that the compiler flag -fobjc-nonfragile-abi2 can be passed to the compiler driver._______________________________________________
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