| Start |
|---|
| When to use a defer statement A As Swift's It can also save time during debugging and profiling, as memory leaks and unused open resources due to forgotten cleanup can be avoided. It can be used to deallocate a buffer at the end of a function: It can also be used to close resources at the end of a function: |
| When NOT to use a defer statement When using a defer-statement, make sure the code remains readable and the execution order remains clear. For example, the following use of the defer-statement makes the execution order and the function of the code hard to comprehend. |
Read Article
https://develop.horje.com/learn/1434/reference