Re: ObjC data structure for C++/ObjC++ objects?
Re: ObjC data structure for C++/ObjC++ objects?
- Subject: Re: ObjC data structure for C++/ObjC++ objects?
- From: Thomas Engelmeier <email@hidden>
- Date: Mon, 10 Nov 2008 19:10:38 +0100
On 08.11.2008, at 02:41, Jonathan Bailey wrote:
I am trying to find a way to create a dynamically-growable objective C
data structure within objective C++ code, such as a
NSMutableDictionary, that can store values that are pointers to an
objective C++ or straight-up C++ object.
Personally, I'd use the PIMPL idiom + std::map. It avoids the mess
only ObjC++ sources can include foo.h.
foo.h:
@class Foo
{
struct FooPriv *priv_;
};
foo.mm:
struct
{
std::map<int, boost::shared_ptr<CppBaseClass> > value_map;
} FooPriv;
- (id) init
{
if( self = [super init] )
{
priv_ = new FooPriv();
}
}
- (void) dealloc
{
delete priv_;
[super dealloc];
}
etc...
_______________________________________________
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