Objective-C: enumerating blocks for an array in REVERSE order?

There is an enumerateWithBlock NSArray method, but I need to list it in reverse order, is there a block for this, or do I need to use a for loop, not a fast loop, but the traditional for (int i = array.count - 1 ; i >= 0 ; i--) alone?

Thanks!

+4
source share
2 answers

You can use enumerateObjectsWithOptions: usingBlock: passing the NSEnumerationReverse parameter as a parameter.

+19
source

You can use reverseObjectEnumerator

 for (id someObject in [myArray reverseObjectEnumerator]) { // print some info NSLog([someObject description]); } 

Hope this helps!

+6
source

Source: https://habr.com/ru/post/1444977/


All Articles