ios - OR statement in the arguments of method -
i have method this:
-(void)examplesend:(nsstring *)gateway byparams:(nsdictionary *)params{ ... }
now want change params
, input argument, support both nsdictionary
, nsarray
. how can in objective-c ?
change type id
instead of nsdictionary
, make sure should check inside method if nsdictionary
or nsarray
before performing class specific actions on it, otherwise cause crash.
-(void)examplesend:(nsstring *)gateway byparams:(id)params{ if([params iskindofclass:[nsdictionary class]]){ }else{ } ... }
Comments
Post a Comment