title: iPhone Programming setNeedsDisplay not working
body: <p>Implemented my own drawRect method and I'm trying to redraw the shape from a Controller class and I can't figure out how to correctly implement setNeedsDisplay to redraw the UIView.  Please help!!</p>
  
  <p>I know the code is ugly, but here is the custom method:</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect{
  // Drawing code
  NSArray *kyle = [self pointsForPolygonInRect:rect numberOfSides:[pshape numberOfSides]];
  CGContextRef c = UIGraphicsGetCurrentContext();
  
  int counter = [kyle count];
  NSLog(@"counter: %d",counter);
  int i = 0;
  BOOL first = YES;
  
  NSValue *kylevalue;
  CGPoint thePoint;
  for (i = 0; i &lt; counter; i++) {
      kylevalue = [kyle objectAtIndex:i];
      thePoint = [kylevalue CGPointValue];
      if (first) { //start.
          CGContextMoveToPoint(c, thePoint.x, thePoint.y+5.0);
          first = NO;
      } else { //do the rest
          CGContextAddLineToPoint(c,  thePoint.x, thePoint.y+5.0);
      }
  }
  CGContextClosePath(c); //solid color
  CGContextDrawPath(c, kCGPathFillStroke);    
  </code></pre>
  
  <p>}</p>