I have two NSMutableArray: arrayone and arraytwo
arrayone and arraytwo are full of objects, but I want cancel all objects of arrayone and insert in this array all objects of arraytwo. then I want overwrite arrayone with arraytwo.
I have two NSMutableArray: arrayone and arraytwo
arrayone and arraytwo are full of objects, but I want cancel all objects of arrayone and insert in this array all objects of arraytwo. then I want overwrite arrayone with arraytwo.
Lets say you have:
NSMutableArray *arrayOne = [[NSMutableArray alloc]initWithObjects:@"A", @"B",nil ];
NSMutableArray *arrayTwo = [[NSMutableArray alloc]initWithObjects:@"C", @"D",nil ];
Now you can remove all objects and insert the new objects like this:
[arrayOne removeAllObjects];
[arrayOne addObjectsFromArray:arrayTwo];
Or release the array and initialize a new one like this:
[arrayOne release];
arrayOne = [[NSMutableArray alloc] initWithArray:arrayTwo];
In both cases NSLog(@"%@",arrayOne); shows:
(
C,
D
)