简体   繁体   English

NSDictionary中的NSNumber始终为null

[英]NSNumber in NSDictionary is always null

I'm building a project and want to add a NSNumber into a NSDictionary. 我正在构建一个项目,并希望将NSNumber添加到NSDictionary中。 But the it crashed because of the null value. 但由于空值,它崩溃了。 So, I created another small program to check what happened. 所以,我创建了另一个小程序来检查发生了什么。 As you can see in the snapshot: Why the the value of NSNumber in NSDictionary is null? 正如您在快照中看到的:为什么NSDictionary中NSNumber的值为null? 断点快照

I've run your code and I could reproduce the problem. 我运行你的代码,我可以重现这个问题。 But it seems like a debugger problem. 但它似乎是一个调试器问题。 For instance, if after your dictionary is created, go to the console and try printing the dictionary. 例如,如果在创建字典后,请转到控制台并尝试打印字典。

po dictionary

My result is like: 我的结果是:

$4 = 0x2083e770 {
    number = 1;
}

So it's not null at all. 所以它根本不是空的。 Also, after that, anum is assigned correctly and b is set to YES. 此外,在此之后,正确分配anum并将b设置为YES。 So it really looks like a debugger issue instead of a bug from you. 所以它看起来像一个调试器问题,而不是你的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM