Skip to content

Instantly share code, notes, and snippets.

@hpyhacking
Created December 26, 2012 01:21
Show Gist options
  • Save hpyhacking/4376961 to your computer and use it in GitHub Desktop.
Save hpyhacking/4376961 to your computer and use it in GitHub Desktop.
change NSMutableArray by reference
NSArray *ma1 = [@[@"a", @"b", @"c"] mutableCopy];
NSArray *ma2 = [@[@"a", @"b", @"c"] mutableCopy];
NSArray *array = @[ma1, ma2];
NSLog(@"orign %@", array);
[[array objectAtIndex:0] replaceObjectAtIndex:0 withObject:@"X"];
[[array objectAtIndex:1] replaceObjectAtIndex:2 withObject:@"Y"];
NSLog(@"changed %@", array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment