0
func scroller() {
    let delay = 0.1 * Double(NSEC_PER_SEC)

    DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
        if self.chatMessages.count > 0 {
            let lastRowIndexPath = IndexPath(forRow: self.chatMessages.count - 1, inSection: 0)
            self.tblChat.scrollToRowAtIndexPath(lastRowIndexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: true)
        }
    }
}

I am getting an error where it says Argument labels '(forRow:, forSection:) do not match any available overloads, any help?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jennifer
  • 11
  • 2

1 Answers1

3

In Swift 3 you need:

let lastRowIndexPath = IndexPath(row: self.chatMessages.count - 1, section: 0)
self.tblChat.scrollToRow(at: lastRowIndexPath at: .bottom animated: true)

You seem to be trying to use the older Swift 2 APIs.

Look at the documentation for IndexPath and UITableView. And try to use Xcode's autocompletion when typing code. Of course if you copy and pasted older code then that doesn't help.

rmaddy
  • 314,917
  • 42
  • 532
  • 579