Probably many posts have already been devoted to explain the use of defer keyword in Swift. But my two cents here. Defer is the new keyword added to the Swift 2.0 to handle unseen developer bugs and simplify the program flow.
For more detailed and official explanation of defer,