I tried different options to confirm that this is really a mistake, and my findings:
- If you do not assign
c in someProperty code someProperty , both instances will print the string in the corresponding deinit s. A true strong reference loop does not fade. - If
SomeClass not inherited from NSObject , this error does not occur. - When using Swift 2.2, this does not happen.
- When using iOS 9- this does not happen.
- Once
someProperty set to nil somewhere in the code, both instances of deinit ed. The Xcode 8 memory debugger confirms that there are no memory leaks. However, in Tools, this change is not reflected - rightfully, since a real memory leak will probably not be resolved.
FYI, this happens not only when it is assigned to the UIViewController property. Initially, I learned about this behavior in one object.
source share