According to https://stackoverflow.com/a/38144190/72437
The reason is that the immediately applied closure {}() is considered @noescape. It does not retain the captured self.
and https://oleb.net/blog/2016/10/optional-non-escaping-closures/
However, it’s impossible to create a reference cycle with a non-escaping closure — the compiler can guarantee that the closure will have released all objects it captured by the time the function returns.
However, I still do not understand why @nonescaping
closure does not retain self
, and doesn't require [weak self]
? Can someone explain this concept in simpler manner?