Member-only story
A Better Way To Test Reference Cycles in iOS
How to test that objects are properly deallocated without introducing overhead in your production code
Testing is one of my favorite topics, that’s no news. And I love to research and find new ways to improve how we can testing our apps and libraries.
One of the hardest things to test in iOS are reference cycles. I already wrote about testing reference cycles a year and a half ago, but that solution was not completely satisfying: it forced to pollute production code with closures and observers.
Recently, resuscitated that post with other suggestions on how to achieve a similar result. I’m very grateful for those suggestions as I love to discuss these topics with the iOS community, but they both suffered from the same issue: they require adding overhead code for the sake of testing. Yes, you can compile them out using precompiler pragmas like #if DEBUG
but they will still make the code less readable.
Last year, thanks also to , I learned a different, polished way to test reference cycles and today I want to share it with everyone.