iOS: Reversing a NSArray

You can reverse a NSArray by writing your own loop iterating from the end towards the beginning and using a second array to add the items in reverse order.

Or you can simply use - (NSEnumerator *)reverseObjectEnumerator  from the NSArray class.

NSArray *sortedArray = [....]
NSArray *reversedArray = [[sortedArray reverseObjectEnumerator] allObjects];

I've just launched a new side project of mine:

Bugfender - A modern remote logger tailor-made for mobile development

It's currently free and you can sign up here:

Any kind of feedback is more than appreciated :-)

No comments:

Post a Comment