Reputation: 2841
This piece of code ran fine in Swift 3, but now after conversion of code by the Xcode into Swift 4, it is throwing error. I am presenting the next scene in the main queue, based on the values I got from the web-service.
DispatchQueue.main.async {
[weak self] value in
self?.router?.invokeTheSegueAfterTheWebService(navigationKey: arrayElementsGot["questionType"] as! String, givenViewController: self!)
}
Upvotes: 1
Views: 998
Reputation: 185671
In Swift 3, the value
parameter was inferred to have the type ()
.
Swift 4 no longer allows you to provide a single parameter to blocks that contextually should take a different number of parameters. So your code should look like
DispatchQueue.main.async {
[weak self] in
self?.router?.invokeTheSegueAfterTheWebService(navigationKey: arrayElementsGot["questionType"] as! String, givenViewController: self!)
}
If you look at the error you got, it says that it expected () -> Void
(e.g. a block with no parameters) but you passed it (_) -> ()
(e.g. a block with one parameter of unknown type).
Upvotes: 3