Last active
October 16, 2019 13:04
-
-
Save devxoul/a376db02653ccff732d365636d486f03 to your computer and use it in GitHub Desktop.
Does UIViewController get deallocated synchronously? NO. (if view is loaded)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weak var weakViewController: UIViewController? | |
_ = { | |
let viewController = UIViewController() | |
viewController.loadViewIfNeeded() // this line prevents from deallocation | |
weakViewController = viewController | |
}() | |
XCTAssertNil(weakViewController) // (fail) weakViewController = Optional(<UIViewController: 0x7fd55e705080>) | |
DispatchQueue.main.async { | |
print(weakViewController) // nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arc 에서의 autorelease 최적화와 관련한 이슈라고 생각합니다. 같은 문제를 일으키는 좀 더 간단한 구현체를 만들어보는 중이네요. (아니면 -fno-objc-arc 플래그로 컴파일을 해봐야하나 .. 고민)