title: Setting CGContextSetStrokeColorWithColor with a UIColor that was passed as a parameter
body: <p>I'm having some problems with my code. I am unable to set the circle the color that was passed in the constructor. When it runs I receive the following error, " <strong>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -CGColor not defined for the UIColor ; need to first convert colorspace.</strong>'" Here is my code</p>
  
  <p>MainViewController.m</p>
  
  <pre><code>#import "CircleGenerator.h"
  CircleGenerator *newCircle =[[CircleGenerator alloc]initWithFrame:frame initWithColor:[UIColor blackColor];
  </code></pre>
  
  <p>CircleGenerator.h</p>
  
  <pre><code>@property(nonatomic, strong) UIColor *circleColor;
  
  - (id)initWithFrame:(CGRect)frame initWithColor:(UIColor*)color;
  </code></pre>
  
  <p>CircleGenerator.m</p>
  
  <pre><code>   - (id)initWithFrame:(CGRect)frame initWithColor:(UIColor *)color
  {
      self = [super initWithFrame:frame];
      if (self) {
          // Initialization code
          _circleColor = [[UIColor alloc]init];
          _circleColor = color;
  
          NSLog(@"the color is %@", _circleColor);
  
      }
      return self;
  }
  
  
  - (void)drawRect:(CGRect)rect
  {
  
  
      // Init a CGContecRef
      CGContextRef context = UIGraphicsGetCurrentContext();
      // Makes circle a bit smaller then the rectange to prevent it from getting cut off
      CGRect border = CGRectInset(rect, 5, 5);
      // Draws circle
      CGContextAddEllipseInRect(context, border);
      // Changes the color of the line
      CGContextSetStrokeColorWithColor(context, [_circleColor CGColor]);
      // Sets the line to the appropriate thickness
      CGContextSetLineWidth(context, 5.0);
      // Draws the circle onto the UIView
      CGContextStrokePath(context);
  
  }
  </code></pre>
  
  <p>I am having problems with the following line from CircleGenerator.m</p>
  
  <pre><code>        CGContextSetStrokeColorWithColor(context, [_circleColor CGColor]);
  </code></pre>
  
  <p>If I put [UIColor blackColor] in place of _circleColor, the code compiles without any problems. Any ideas with with what I am doing incorrectly?</p>