Re: Help with NSPointerArray and NSMapTable
Christiaan Hofman <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sep 24, 2009, at 4:30, Adam R. Maxwell wrote: > > On Sep 23, 2009, at 2:25 PM, Christiaan Hofman wrote: > >> Still what to do with NSMapTable? The docs are really weird on this >> point, I'd say contradictory. Basically, they say I can use non- >> object pointers, but it may not work (so I may not be able to use >> them). So, then, can I use non-object pointers or can't I? Can >> anyone be more specific? > > I can't help with that confusion, unfortunately :). The only thing > I see in the docs is that you should use the C API for NSMapTable > with non-object pointers. Have you thought about writing an Obj-C > wrapper around STL containers (maybe std::map and std::vector?) > instead of messing around with primitive types in Foundation > containers? > Well, I thought that with these collections Apple had finally introduced Cocoa API to replace CF collections (like CFDictionary) with arbitrary data. Perhaps I'm wrong? But I do think it's strange that they first explicitly advertise that you can use arbitrary pointers (in an itemized list!) and right away warn you shouldn't do that! My point about API is that it should either be supported or it should not be supported, otherwise it's not API but SPI. And if it's partially supported then it should be explicitly and clearly noted what is not supported in some cases. These docs don't make the cut for me (radar filed, of course). And I think it was a very poor choice to not make NSPointerArray API consistent with NSMapTable and NSHashTable. I always understood that the Cocoa frameworks were supposed to have a simple API with a small number of versatile objects, AOT C++ and STL which have a large number of specialized objects. I think these newer additions go against this spirit, they really don't look well thought through to me. Christiaan