我的应用程序偶尔会崩溃
2012-10-10 23:19:24.039 [26442:850f] -[NSNull allKeys]: unrecognized selector sent to instance 0x7fff741cbea0
2012-10-10 23:19:24.040 [26442:850f] *** Terminating app due to uncaught exception of class 'nil'
在调用[obj isKindOfClass:[NSDictionary class]]
allKeys:
测试
如果我故意致电[[NSNull null] allKeys]
,它会与
2012-10-11 16:22:15.606 [14939:403] -[NSNull allKeys]: unrecognized selector sent to instance 0x7fff73659f00
2012-10-11 16:22:15.622 [14939:403] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull allKeys]: unrecognized selector sent to instance 0x7fff73659f00'
我想知道导致Terminating app due to uncaught exception of class 'nil'
的情况,以便我可以调试此问题。
答案 0 :(得分:0)
1:因为NSNull没有响应消息[allKeys],所以它会引发异常。
2:您应该检查您的对象是否可以[respondsToSelector:@selector(allKeys)]
3:如果你的NSNull类objet传递了[obj isKindOfClass:[NSDictionary class]],那么你的控制语句就会出现问题