Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining multiple NSArrays

How can I combine multiple NSArrays into one array with alternating values? For example.

Array One: Orange, Apple, Pear

Array Two: Tree, Shrub, Flower

Array Three: Blue, Green, Yellow

The final array would need to be: Orange, Tree, Blue, Apple, Shrub, Green, etc

like image 718
Brandon Schlenker Avatar asked Jan 22 '26 00:01

Brandon Schlenker


1 Answers

[@[@[@1,@2],@[@3,@4],@[@5,@6]] valueForKeyPath:@"@unionOfArrays.self"]

So once you have a array of arrays you call unionOfArrays collection operator.

like image 93
Adrian Avatar answered Jan 24 '26 17:01

Adrian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!