How to add an array to the top of another array in iOS

No comments on How to add an array to the top of another array in iOS

Written by

in

I found two good solutions in StackOverflow:

[existingArray replaceObjectsInRange:NSMakeRange(0,0)
                withObjectsFromArray:newArray];

And the second one:

NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange: (NSRange) {0, [newArray count]}];
[existingArray insertObjects: newArray atIndexes: indexes];

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *