Help with NSPointerArray and NSMapTable
Christiaan Hofman <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
I am trying to create arrays and dictionaries containing non-object types like NSInteger, CGFloat, and structs like NSRect. This should be possible using NSPointerArray/NSMapTable and appropriate pointer functions. But I am very much confused about which pointer function options to use and how to add/remove values. The documentation is very terse, IMHO insufficient, and I was not able to find any sample code. So perhaps someone here could help me and/or point me to some samples. Her a few more specifics. For an array of integers, I tried an NSPointerArray with options (NSPointerFunctionsMallocMemory | NSPointerFunctionsCopyIn | NSPointerFunctionsIntegerPersonality). Would that be correct, and would that require more settings? Also, does NSPointerFunctionsIntegerPersonality refer to the pointers itself, or the values it points to. I.e., should I then pass pointers to the integers or the integers itself typed as void*? In both cases I get crashes, so I don't do it correct. But I can't figure out what. Similar for structs and CGFloat. Do I need to use NSPointerFunctionsStructPersonality also for CGFloat (because that's the only one that makes sense to me)? And for both of these, would it suffice to use options (NSPointerFunctionsMallocMemory | NSPointerFunctionsCopyIn | NSPointerFunctionsStructPersonality) and supply a simple sizeFunction that just returns the size calculated using sizeof? And do I pass them by address? Thanks, Christiaan