Reputation: 1745
I am trying to simply reverse the order in which the data is displayed in the tableview. self.results is an array of objects. I got this warning:
Result of call to 'reverse()' is unused
self.results?.reverse()
self.tableView.reloadData()
Just wondering if someone could shed some light on this warning as to what that means and how could the data inserted be displayed in the order of last inserted to be on top (reversed). Thanks
Upvotes: 0
Views: 2193
Reputation: 77651
The function reverse()
is not an "in place" or "mutating" function.
It will take the array you call the function on and return a new array that is in the reverse order.
When you do this...
self.results.reverse()
Then look at self.results
you will see it is in the same order.
You could do this...
self.results = self.results.reverse()
Upvotes: 6