James Skidmore James Skidmore - 1 year ago 72
Objective-C Question

In Objective-C, how do I test the object type?

I need to test whether the object is of type

. How can I accomplish this? Is there some type of "isoftype" method?

mmc mmc
Answer Source

If your object is myObject, and you want to test to see if it is an NSString, the code would be:

[myObject isKindOfClass:[NSString class]]

Likewise, if you wanted to test myObject for a UIImageView:

[myObject isKindOfClass:[UIImageView class]]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download