Soheil Novinfard Soheil Novinfard - 1 year ago 72
Objective-C Question

OR statement in the arguments of method

I have a method like this:

-(void)exampleSend:(NSString *)gateway byParams:(NSDictionary *)params{

Now I want to change
, which is an input argument, to something that support both
. How can I do this in objective-c ?

Answer Source

Change the type to id instead of NSDictionary and make sure you should check inside your method if its NSDictionary or NSArray before performing any class specific actions on it, otherwise it will cause a crash.

-(void)exampleSend:(NSString *)gateway byParams:(id)params{

    if([params isKindOfClass:[NSDictionary class]]){


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download