Greetings, Jonathan,If you can afford to target 10.5+ only, you can use an NSMapTable, which is a mutable type of collection "modeled after NSDictionary" but "can contain arbitrary pointers (its contents are not constrained to being objects)"; it can also "hold weak references to its keys and/or values." It's probably a little more friendly than using CFMutableDictionary. Hope this helps!
Cheers, Andrew On Nov 7, 2008, at 9:12 PM, Jonathan Bailey wrote:
Hi Michael - Thanks much for your response. I actually did originally intend to use an STL map, but I couldn't get it to work. It seemed that when I added a C++ object to a map declared as an instance variable within my ObjC++ class's header file, this generated an "EXC_BAD_ACCESS" signal - and no exception thrown. As a test, I created a temp STL map in the implementation/.mm file for this class, and added my C++ object to that map and it seemed to work fine. So I assumed that templated classes weren't supported as instance variables for an ObjC++ class. I'll definitely investigate using CFMutableDictionary instead if indeed STL won't work for instance variables. Thanks, JBOn Fri, Nov 7, 2008 at 10:29 PM, Michael Ash <[EMAIL PROTECTED]> wrote: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 Cdata 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 areparts of the NSMutableDictionary API which assume that you are storingonly Objective-C objects, but for dictionaries which actually arestoring Objective-C objects it's very useful. This also means that youcan 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/jonb%40drumwell.net This email sent to [EMAIL PROTECTED]_______________________________________________ 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/andrew.merenbach%40ucla.edu This email sent to [EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]