iPhone 如何检查一个对象的类型? [英] iPhone how to check the type of an Object?
本文介绍了iPhone 如何检查一个对象的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查一个对象的类型.我该怎么做?
I want to check the type of an Object. How can I do that?
场景是我得到了一个对象.如果该对象是 A 类型,则执行一些操作.如果它是类型 B 则做一些操作.当前对象的类型是 C,它是 A 和 B 的父对象.
The scenario is I'm getting an object. If that object is of type A then do some operations. If it is of type B then do some operations. Currently the type of the object is C that is parent of A and B.
我有两个类AViewController
和BViewController
.我在 UIViewController
中得到的对象.现在如何判断对象是AViewController
还是BViewController
?
I have two classes AViewController
andBViewController
. The object I'm getting in UIViewController
. Now how to check whether the object is AViewController
or BViewController
?
推荐答案
if([some_object isKindOfClass:[A_Class_Name class]])
{
// do somthing
}
这篇关于iPhone 如何检查一个对象的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文