NSMutableDictionary returns 0xffffffff instead of nil when a key doesn't exist
I have an NSMutableDictionary that is doing something strange:
(gdb) po listenerRegistry
{
}
(gdb) po productI开发者_Go百科D
com.mycompany.productid
(gdb) po [listenerRegistry objectForKey:[productID stringValue]]
0xffffffff does not appear to point to a valid object.
(gdb) po [listenerRegistry class]
__NSCFDictionary
(gdb)
According to the docs, nil
is supposed to be returned for keys that aren't in the dictionary.
Has anyone else seen this before?
Answering my own question.
The objects inside the NSMutableDictionary
are of the type id <MyObserverProtocol>
, and it would appear that Monolo was right in his observation that the returned value looks like NSNotFound
.
Apparently, Foundation classes return NSNotFound
when asked for items of that type when they don't exist or aren't found (as discussed here). While the documentation lists NSArray
s explicitly, I feel compelled to believe the same is happening in my case.
精彩评论