title: iOS 5 - Draw a circle on touch
body: <p>I want to make my app to draw a circle centered at the touch coordinates. </p>
  
  <p>Here's the code I have right now, it is messed up for sure, I haven't had any practice with drawing things and working with context. What am I missing here? Thanks in advance. </p>
  
  <p>View controller is a subclass of UIViewController</p>
  
  <pre><code>@implementation ViewController
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
      // Custom initialization
  }
  return self;
  }
  
  - (void)viewDidLoad
  {
  [super viewDidLoad];
  }
  
  - (void)viewDidUnload
  {
  [super viewDidUnload];
  }
  
  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
  UITouch *theTouch = [touches anyObject];
  
  [self doSomething];
  
  //[self.view setNeedsDisplay];
  
  }
  
  - (void) drawCircleAtPoint:(CGPoint)point withRadius:(CGFloat)radius inContext:(CGContextRef)context{
  UIGraphicsPushContext(context);
  CGContextBeginPath(context);
  CGContextAddArc(context, point.x, point.y, radius, 0, 2*M_PI, YES);
  CGContextFillPath(context);
  UIGraphicsPopContext();
  }
  
  - (void)drawRect:(CGRect)rect
  {
  CGPoint point;
  CGContextRef context = UIGraphicsGetCurrentContext();
  point.x = self.view.bounds.origin.x + self.view.bounds.size.width/2;
  point.y = self.view.bounds.origin.y + self.view.bounds.size.height/2;
  CGContextSetLineWidth(context, 5.0);
  [[UIColor whiteColor] setFill];
  [self drawCircleAtPoint:point withRadius:50 inContext:context];
  
  }
  
  @end
  </code></pre>
  
  <p>Here I wanted it to draw the circle at least on the center of the screen, but I can't do even this.</p>