I had been working on your question an here are my results, first of all you need to be sure that your section have the tag that you need later, so you need to use this code instead of your viewDidLoad()code

and later you can get your section and change the title, but if you don´t call
section.reload() in the interface will never be updated, so add section.reload() below of your section.header?.title = "Contacts: \(contacts.count) selected"