Hello everyone!
A simple answer to this super simple question would be great! Here is the pseudcode:
NSMutableArray Africa = [Lion, Tiger, Zebra];
NSMutableArray Canada = [Polar Bear, Beaver , Loon];
NSMutable Array Animals = Africa + Canada;
What I want to end up with:
Animals = [Lion, Tiger, Zebra, Polar Bear, Beaver, Loon];
What is the proper syntax to achieve this in Objective-C/ Cocoa?
Thanks so much!
From stackoverflow
-
To create an array:
NSMutableArray* africa = [NSMutableArray arrayWithObjects: @"Lion", @"Tiger", @"Zebra", nil]; NSMutableArray* canada = [NSMutableArray arrayWithObjects: @"Polar bear", @"Beaver", @"Loon", nil];To combine two arrays you can initialize array with elements of the 1st array and then add elements from 2nd to it:
NSMutableArray* animals = [NSMutableArray arrayWithArray:africa]; [animals addObjectsFromArray: canada];
0 comments:
Post a Comment