How do I test which class an object is in Objective-C?

前端 未结 6 1190

How do I test whether an object is an instance of a particular class in Objective-C? Let\'s say I want to see if object a is an instance of class b, or class c, how do I go

6条回答
  •  情深已故
    2020-11-30 17:12

    If you want to check for a specific class then you can use

    if([MyClass class] == [myClassObj class]) {
    //your object is instance of MyClass
    }
    

提交回复
热议问题