On Fri, Nov 7, 2008 at 8:41 PM, Jonathan Bailey <[EMAIL PROTECTED]> wrote:
> Hi all -
>
> 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.
>
> NSMutableDictionary seems to only accept pointers to objective C
> objects, however, and not to arbitrary objects. This seems like a
> simple thing to do but I am a bit stumped. Does anyone know of a way
> to do this?

CFMutableDictionary will accept arbitrary pointers, and allows you to
provide callbacks so that it knows how to work with them.

As an added bonus, CFMutableDictionary is "toll-free bridged" to
NSMutableDictionary, meaning that you can simply cast the pointer and
use it. The bridging is not 100% with custom callbacks, as there are
parts of the NSMutableDictionary API which assume that you are storing
only Objective-C objects, but for dictionaries which actually are
storing Objective-C objects it's very useful. This also means that you
can store it in other Cocoa collections like NSArray, other
NSDictionaries, etc.

And note that if you're using Objective-C++, there's nothing
preventing you from using STL collections for this sort of thing, if
they do what you like.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to