Is there a way to use any of Apple's provided libraries or methods to zip
two arrays together?
For example, if I have the following arrays
NSArray *one = @[@"foo", @"bar", @"bannana"];
NSArray *two = @[@"zebra", @"dog", @"cat"];
I want the result to be
@[@"foo", @"zebra", @"bar", @"dog", @"bannana", @"cat"]
I am aware that I could simply loop over them and add them to an other array, but I want to know if there is a better way to do it. I am not worried about performance.
You can assume the arrays are of the same length.
Edit :
I see now I was mistaken about the zip
function, and that what I'm looking for here could probably be achieved in combination with flatten
.
(I am constrained to using objective-c)