Just by studying Swift and came up with the same question.
The closest I could get was the following:
if let UOW = (try UnitOfWork() as UnitOfWork?) { }
This is a little hack to optional binding, but seems to work. You will need to make sure your class has the deinit specified above, named above by Alexander. I found that even if my init throws an exception, the deinit method is still called as soon as you exit the scope in the IF statement.
NOTE. Make sure you use weak links, if applicable, to make sure your deinit is really caused!
Most likely, more Swifty uses the DO block for your review:
do { let UOW = try UnitOfWork()
What is the advantage of avoiding the death pyramid with your pseudo-blocks (for example, you will get C #)
source share