Re: Help with NSPointerArray and NSMapTable

"Adam R. Maxwell" <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Sep 24, 2009, at 2:11 AM, Christiaan Hofman wrote:

>
> On Sep 24, 2009, at 4:27, Adam R. Maxwell wrote:
>
>>
>> On Sep 21, 2009, at 12:14 PM, Christiaan Hofman wrote:
>>
>>> Apart from this, the 64-bit docs warn against type-casting an  
>>> NSInteger as a pointer, but that seems to be exactly what  
>>> NSPointerArray expects me to do? If they go against their own docs  
>>> I really think they should be more clear.
>>
>> Can you point to where the docs warn against this?
>>
>> thanks,
>> Adam
>
> Right in the Overview of the NSMapTable documentation:
>
> "It can contain arbitrary pointers (its contents are not constrained  
> to being objects).

Oops!  I should have been more specific: where do the docs warn  
against casting NSInteger to a pointer?  I thought that would be  
pointer-size on 32 or 64 bit (vs int or long).

> "Note that only the options listed in “NSMapTableOptions” guarantee  
> that the rest of the API will work correctly—including copying,  
> archiving, and fast enumeration. If you use other NSPointerFunctions  
> options, the map table may not work correctly, or may not even be  
> initialized correctly."

Nice.  That's the same caveat that an Apple engineer pointed out to me  
for CFDictionary (as an excuse for -[NSMutableDictionary  
setObject:forKey:] incompatibility with pointer equality callbacks).   
Based on that, I'd avoid the NSMapTable class and either use  
CFDictionary or the NSMapTable C API.

_______________________________________________
MacOSX-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.