title: How to swizzle a class method on iOS?
body: <p>Method swizzling works great for instance methods. Now, I need to swizzle a class method. Any idea how to do it?</p>
  
  <p>Tried this but it doesn't work:</p>
  
  <pre><code>void SwizzleClassMethod(Class c, SEL orig, SEL new) {
  
  Method origMethod = class_getClassMethod(c, orig);
  Method newMethod = class_getClassMethod(c, new);
  
  if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
      class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
  else
      method_exchangeImplementations(origMethod, newMethod);
  }
  </code></pre>