
Before objc4–818.2, the runtime system will flush the method cache list of all objc class when using method_exchangeImplementations. Because the API of method_exchangeImplementations only requires two “Methods” as parameters, and the runtime system does not know the “Method” belongs to which class, it has to flush all the caches to keep the method dispatch system running well.
However, there is a new optimization in objc4–818.2. The runtime system will judge whether the replacing method is in the method cache list of a certain class. It does not flush the cache if not.