0

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?

1
  • 1
    Use kindOfclass instead
    – meda
    Apr 12, 2014 at 21:56

1 Answer 1

1

You need to use -isKindOfClass:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.