Search code examples
swiftswift3swift4

How to reverse an array in Swift?


How can I print the following array in reverse order?

var toDoListReverse = ["Take out garbage", "Pay bills", "Cross off finished items"]

Solution

  • Here is code for swift 3

    let array = ["IOS A", "IOS B", "IOS C"]
    for item in array.reversed() {
        print("Found \(item)")
    }