Swift 2.0 introduced a new keyword: defer
What is the correct way to use this keyword and what should I follow?
Because swift uses ARC, memory management is usually careful about automatic. Thus, deferring is only required for memory management in cases where outdated low-level / non-arc calls are used, right?
Other cases include file access, I suppose. And in these cases, defer will be used to close the "file pointer".
When to use, I use defer in the "real world" (tm) of iOS / OSX development. And when it would be a bad idea to use.
source
share