开发者

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 NSArrays explicitly, I feel compelled to believe the same is happening in my case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜