Reverse NSMutableArray Reverse NSMutableArray ios ios

Reverse NSMutableArray


themutablearray=[[[themutablearray reverseObjectEnumerator] allObjects] mutableCopy];


theMutableArray=[[[theMutableArray reverseObjectEnumerator] allObjects] mutableCopy];


Here is the swift version of Reverse NSMutableArray

mutablearray =  NSMutableArray(array: YourMutablearray.reverseObjectEnumerator().allObjects).mutableCopy() as! NSMutableArray

In pure Swift, you can use reverse()

let array = ["Apples", "Peaches", "Plums"]for item in array.reverse() {     print("Found \(item)")}

Source: hacking with swift

------ OR ------

var a = [String]()a.append("1")a.append("2")a.append("3")print(Array(a.reverse())) // In swift 3.0, method is `reversed()`