title: How to stub a class method in OCMock?
body: <p>I often find in my iPhone Objective-C unit tests that I want stub out a class method, e.g. NSUrlConnection's +sendSynchronousRequest:returningResponse:error: method.</p>
  
  <p>Simplified example:</p>
  
  <pre><code>- (void)testClassMock
  {
      id mock = [OCMockObject mockForClass:[NSURLConnection class]];
      [[[mock stub] andReturn:nil] sendSynchronousRequest:nil returningResponse:nil error:nil];
  }
  </code></pre>
  
  <p>When running this, I get:</p>
  
  <pre><code>Test Case '-[WorklistTest testClassMock]' started.
  Unknown.m:0: error: -[WorklistTest testClassMock] : *** -[NSProxy doesNotRecognizeSelector:sendSynchronousRequest:returningResponse:error:] called!
  Test Case '-[WorklistTest testClassMock]' failed (0.000 seconds).
  </code></pre>
  
  <p>I've had a really hard time finding any documentation on this, but I assume that class methods aren't supported by OCMock.</p>
  
  <p>I found this tip after a lot of Googling. It works, but is very cumbersome:
  <a href="http://thom.org.uk/2009/05/09/mocking-class-methods-in-objective-c/" rel="noreferrer">http://thom.org.uk/2009/05/09/mocking-class-methods-in-objective-c/</a></p>
  
  <p>Is there anyway to do this within OCMock? Or can someone think of a clever OCMock category object that could be written to accomplish this sort of thing?</p>