In Objective-C, what is the equivalent of Java’s “instanceof” keyword?

I would like to check whether an object (e.g. someObject) is assignable (cast-able) to a variable of another type (e.g. SpecifiedType). In Java, I can write:

someObject instanceof SpecifiedType

A related question is finding whether the runtime type of an object is equal to a another type. In Java, I can write:

someObject.getClass().equals(SpecifiedType.class)

How can this be done in Objective-C?

3 Answers
3

Leave a Comment