• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ObjC data structure for C++/ObjC++ objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >ObjC data structure for C++/ObjC++ objects? (From: "Jonathan Bailey" <email@hidden>)

  • Prev by Date: Badged icons
  • Next by Date: Re: Responder Chain & Multiple Windows
  • Previous by thread: Re: ObjC data structure for C++/ObjC++ objects?
  • Next by thread: Re: ObjC data structure for C++/ObjC++ objects?
  • Index(es):
    • Date
    • Thread