Replace (swizzle) an entire class (with all instance and static methods) in Objective-C

428 Views Asked by At

I'm new to method swizzling and now I'd like to do a little more with that on iOS: Is there an easy/elegant way in Objective-C to redirect all calls of an existing class (ClassA) to another class (ClassB, provided it has the exact same methods). I know it's possible to do so with a single method (method swizzling), but what about an entire class?

  • getting the list of all the class's methods and swizzling them one by one?
  • swizzling only the init method of the class?
  • any other way?

The class I want to replace has a lot of static methods and I don't want to touch the original code.

0

There are 0 best solutions below