If I have an NSMutableArray
or NSMutableDictionary
and pass it to a method a la:
-(void)addToThisArray:(NSMutableArray *)theMutableArray
{
[theMutableArray addObject:@"test"];
}
and call it like:
NSMutableArray *theMutableArrayToPass = [[NSMutableArray alloc] init];
[theMutableArrayToPass addObject:@"2"];
[self addToThisArray:theMutableArrayToPass];
Is this a valid way to alter an NSMutableArray
or NSMutableDictionary
? I, of course, would do much more to the array/dictionary than this example, but I am used to Perl, and we pass by reference all the time.