I would like to know how Apple’s -setNeedsLayout works.
I already know that it’s more efficient than directly calling -layoutSubviews, since I might need to do that twice in a method.
And that’s just what I need it for: some custom -setNeedsValidation for a view controller.
But how to realize such a feature?
I can’t confirm that Apple does it exactly this way, but here is a way to do what you’re looking for, and is likely similar to how
setNeedsLayoutis implemented. I haven’t tested this (or even compiled it), but it should give an idea of how to attack the problem as a category onUIViewController. Like UIKit, this is completely thread-unsafe.