hit counter

Timeline

My development logbook

Swift Closure Error: Boolean Is Not Convertible to Void

This piece code here:

1
2
3
dismissViewControllerAnimated(true, completion: { () -> Void in
    let account = Account()
})

throws exception:

Cannot convert the expression's type 'Boolean' to type 'Void'

It is because if the block does not have a return statement, the compiler uses the result of the last statement as the return value

Adding a return () as the last expression to the block fixes the problem