Sometimes, as a developer, I get stuck. This week, I have been stuck by some kind of endless loop or retain cycle that rears its head when I try to access a lazy-loaded class property within a subclass of NSDocument by two child view controllers. Everything worked flawlessly until I added that second view controller. I am at my wits end, and it’s all my fault.

I have tried to access that property only synchronously via a dispatch queue. I have tried making the property not load lazily. I have tried a bunch of other workarounds over the past half-week, but the one that is working is to delay one of the view controller’s accesses of that property by zero seconds (which moves the call to the next run loop). That is a hack, but necessary right now for me to continue developing the app.

I think I’m going to stick with my workaround until the new view controller is completed. After that, I probably have to rip up a bunch of clever code and find a simpler, more straightforward way to set everything up in my NSDocument subclass and its window controller.