鉴于此,是否可以将NSDecimalNumbers提供给任何期望NSNumber的代码?
唯一可能的问题可能是检查参数是NSNumber实例的代码,但由于NSNumber是一个类集群,这样的代码必须检查实例是NSNumber的子类,NSDecimalNumber实例应该通过它试验.
是.The only possible issue might be code that checks that an argument is an instance of NSNumber, but since NSNumber is a class-cluster, code like this would have to check that the instance is a subclass of NSNumber, and NSDecimalNumber instances should pass the same tests.
这就是isKindOfClass:来了,尽管您可能更愿意测试对象是否响应了像integerValue这样的消息.
精彩评论