Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone how to check the type of an Object?

I want to check the type of an Object. How can I do that?

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.

I have two classes AViewController andBViewController. The object I'm getting in UIViewController. Now how to check whether the object is AViewController or BViewController?

like image 586
g.revolution Avatar asked Sep 02 '09 14:09

g.revolution


People also ask

How do you identify an object on iPhone?

Open the Photos app on your ‌iPhone‌ and select a picture with a clearly defined subject, such as a flower or animal. Check the info ("i") icon at the bottom of the screen. If it has a little star over it, tap it – this indicates there's a Visual Lookup you can examine.

How do you find the object type?

Use the typeof operator to get the type of an object or variable in JavaScript. The typeof operator also returns the object type created with the "new" keyword. As you can see in the above example, the typeof operator returns different types for a literal string and a string object.

How can I check if an object is of a given type in Swift?

“Use the type check operator (is) to check whether an instance is of a certain subclass type. The type check operator returns true if the instance is of that subclass type and false if it is not.” Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks.


1 Answers

if([some_object isKindOfClass:[A_Class_Name class]]) {     // do somthing } 
like image 99
Pavel Yakimenko Avatar answered Sep 23 '22 15:09

Pavel Yakimenko