Last active
May 29, 2021 17:35
-
-
Save froggomad/be87f5e7f1f83a3091775ca8e5281452 to your computer and use it in GitHub Desktop.
Test for retain cycles, reusably
This file contains hidden or 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
private func assertNoMemoryLeak(_ instance: AnyObject, file: StaticString = #filePath, line: UInt = #line) { | |
addTeardownBlock { [weak instance] in | |
XCTAssertNil(instance, "Instance should have been deallocated. Potential retain cycle.", file: file, line: line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment