title: Drawing Straight Lines with Finger on iPhone
body: <p><strong>Background:</strong> I am trying to create a really simple iPhone app that will allow the user to draw multiple straight lines on the screen with their finger.</p>
  
  <p>I'm using these two methods in my <code>UIViewController</code> to capture the coordinates of each line's endpoints.</p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  </code></pre>
  
  <p><strong>Question:</strong> 
  I would like the line to show up as soon as <code>touchesEnded</code> has fired and then keep drawing more lines on the screen. How do I do this? I don't necessarily need the code, but I need help with the big picture idea of how to put it together. Also, I'm not a huge fan of xibs and like to do things all programmatically if that affects the answer.</p>
  
  <p><strong>What I've Tried:</strong> I've tried using Quartz 2d but it seems in order to use that, you have to do your drawing in the <code>drawRect</code> method of a separate subclassed view. So I would have to create a new view for each line? and then my coordinates would be messed up b/c I'd have to translate the <code>touches</code> positions from the <code>UIViewController</code> to the view.</p>
  
  <p>I've also tried with OpenGL, which I've had a bit more success with (using the <a href="http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduction/Intro.html" rel="nofollow">GLPaint sample</a> as a template) but OpenGL seems like overkill for just drawing some straight lines on the screen.</p>