This experiment was born out of ReactiveCocoa#3690 – a homeopathy to fix swizzling with more swizzling.
Ideally, there would be a way to simply intercept the call with a custom handler to add some logic. However, that's far from simple:
- Need to handle existing class methods (add vs. replace).
- Need to call original implementation and pass it parameters – no way of doing it in Swift in some cases (via message forwarding), no way of doing it reliably in Objective-C in others (via
va_list
)…
In theory, where my research stops, it's possible to achieve this via scenario:
- Add a block implementation under a random non-clashing selector.