Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Test strong reference cycles within unit tests
public func AssertNoStrongReferenceCycle<T: AnyObject>(
file: StaticString = #file,
line: UInt = #line,
act: () throws -> T
) rethrows {
weak var system: T?
try autoreleasepool {
system = try act()
XCTAssertNil(system, "You've got a reference cycle in \(T.self).", file: file, line: line)
Copy link

erkekin commented Jun 15, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment