mrRany
mrRany

Reputation: 3

xcode - how to get type of NSObject?

I am getting NSObject * myObject on a receiver's side. Sender can send me (NSArray *) or (NSDictionary *) type. How can I check if I get (NSArray *)?

Something like:

NSObject * myObject;
....
if (typeof(myObject) == (NSArray *))
{

} else if (typeof(myObject) == (NSDictionary *))

Any idea?

Upvotes: 0

Views: 1397

Answers (1)

Rich
Rich

Reputation: 8202

You need to use -isKindOfClass:

if ([myObject isKindOfClass:[NSArray class]]) {
    // Array
} else if ([myObject isKindOfClass:[NSDictionary class]]) {
    // Dictionary
}

Upvotes: 1

Related Questions