title: Objective-C: Drawing 2D Graphics in OS X
body: <p>I don't get how to control and manipulate 2D graphics in Objective-C. I don't mind if the answers say how to use Quartz or just Cocoa. I have this code right now:</p>
  
  <pre><code>CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
  CGContextSetRGBFillColor (myContext, 1, 0, 0, 1);
  CGContextFillRect (myContext, CGRectMake (0, 0, 200, 100 ));
  CGContextSetRGBFillColor (myContext, 0, 0, 1, .5);
  CGContextFillRect (myContext, CGRectMake (0, 0, 100, 200));
  </code></pre>
  
  <p>I got this code from Apple's tutorial on Quartz 2D graphics, but when I invoke the method nothing happens. I'm sure I'm just missing some code somewhere.</p>
  
  <p>I'm working on an OS X app in Xcode with 2D graphics, but the tutorials in the Mac Developer Library aren't very detailed, unless I've been reading all the wrong ones. I'm completely new to drawing in Obj-C so this might seem very basic.</p>
  
  <p>If any other info is necessary, please ask in the comments. Thanks.</p>