0

I am trying to print a revered array so the latest entry will be the first one to show up. But the problem I am having is that arrays are not being printed in the way I would like. If i print 3 numbers from 3-1 it shows up 1,3, 2 not 3,2,1. I realize that this is mostly a logic problem but I do not know where to start. I have added the main parts of the array.

   var arrayOfInt = [Int]()

 @IBAction func addNumber(_ sender: Any) {
 arrayOfInt.append(number)
            print(arrayOfInt)
            arrayOfInt = arrayOfInt.reversed()
            let formatter = DateFormatter()formatter.dateFormat = "dd.MM.yyyy HH:mm"
            label.text = arrayOfInt.map { "Date | \(Date.formattedNow) | \($0)" }.joined(separator:"\n")
}
Hamish
  • 78,605
  • 19
  • 187
  • 280

0 Answers0