Imagine a method adding an object to a specific NSMutableArray or NSMutableDictionary. Is it better (and why) to allow only one argument of type id
or to allow two - one for the array and one for the dictionary?
For instance:
- (void)addObjectToArray:(NSMutableArray *)anArray orDictionary:(NSMutableDictionary *)aDictionary;
vs.
- (void)addObjectToArrayOrDictionary:(id);
If you use the first option, I just pass nil
as a parameter depending on what I don't need (i.e. when added to the dictionary, I would pass nil
as an array parameter).
source share