title: ‘invalid context 0x0’ error when using CGContext* functions
body: <pre><code>/*  Adding the Path */
  UserGraphBuff = UIGraphicsGetCurrentContext();
  
  CGContextSetRGBStrokeColor(UserGraphBuff,5,10,0,1);
  CGContextSetLineWidth(UserGraphBuff, 2 );
  
  CGContextBeginPath(UserGraphBuff);  
  
  //line to last user point
  CGContextAddLineToPoint(UserGraphBuff, (*xVal)[sizeof xVal / sizeof *xVal - 1], (*yNewVal)[sizeof yNewVal / sizeof *yNewVal - 1]);
  //line to rest of user points in reverse order
  for (int i = sizeof xVal / sizeof *xVal - 1; i &gt; -1; i--){
      CGContextAddLineToPoint(UserGraphBuff, (*xVal)[i], (*yNewVal)[i]);
  }
  
  //EOFill
  CGContextEOFillPath(UserGraphBuff);
  </code></pre>
  
  <p>Above is the code I am trying to work through. Its supposed to do what CGContext says it does but I am not getting any thing drawn. 
  <strong>I keep getting this error:</strong></p>
  
  <pre><code>Fri Oct 28 13:18:40 case.app testApplication[4127] &lt;Error&gt;: CGContextSetRGBStrokeColor: invalid context 0x0
  Fri Oct 28 13:18:40 case.app testApplication[4127] &lt;Error&gt;: CGContextSetLineWidth: invalid context 0x0
  Fri Oct 28 13:18:40 case.app testApplication[4127] &lt;Error&gt;: CGContextBeginPath: invalid context 0x0
  Fri Oct 28 13:18:40 case.app testApplication[4127] &lt;Error&gt;: CGContextAddLineToPoint: invalid context 0x0
  Fri Oct 28 13:18:40 case.app testApplication[4127] &lt;Error&gt;: CGContextDrawPath: invalid context 0x0
  </code></pre>
  
  <p>I reference the CGContextRef in my header file. </p>
  
  <p>i don't think i understand CGContext well enough nor do i know what CGContextRef should be.</p>