title: Can I use Categories to add class methods?
body: <p>I want to add some class methods to UIColor. I've implemented them and everything compiles fine, but at runtime I get the following error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIColor colorWithHex:]: unrecognized selector sent to class 0x8d1d68'</p>
  </blockquote>
  
  <p>Here's the header file:</p>
  
  <pre><code>@interface UIColor (Hex) 
  + (UIColor*) colorWithHex: (NSUInteger) hex;
  @end
  </code></pre>
  
  <p>Here's the implementation:</p>
  
  <pre><code>#import "UIColor+Hex.h"
  
  
  @implementation UIColor (Hex)
  
  + (UIColor*) colorWithHex: (NSUInteger) hex {
      CGFloat red, green, blue, alpha;
  
      red = ((CGFloat)((hex &gt;&gt; 16) &amp; 0xFF)) / ((CGFloat)0xFF);
      green = ((CGFloat)((hex &gt;&gt; 8) &amp; 0xFF)) / ((CGFloat)0xFF);
      blue = ((CGFloat)((hex &gt;&gt; 0) &amp; 0xFF)) / ((CGFloat)0xFF);
      alpha = hex &gt; 0xFFFFFF ? ((CGFloat)((hex &gt;&gt; 24) &amp; 0xFF)) / ((CGFloat)0xFF) : 1;
  
      return [UIColor colorWithRed: red green:green blue:blue alpha:alpha];
  }
  @end
  </code></pre>
  
  <p>I've found something about adding -all_load to the linker flags, but doing that gives the same result. This is on the iPhone, if it wasn't clear.</p>