Trailing closure for dismiss() in Swift4

In Swift 4 (IOS App), if I try to dismiss a viewController (as in Swift3), with :

self.dismiss(animated: true) { (completion) in … }

 

I get a compiler error:

Cannot convert value of type ‘(_) -> ()’ to expected argument type ‘(() -> Void)?’

 

Changing to

self.dismiss(animated: true, completion: { … })

 

works.

 

How to write this with a trailing closure ?

Powered by WPeMatico

About

You may also like...

Comments are closed.