title: Passing object from controller to a view
body: <p>I'm following <a href="http://www.stanford.edu/class/cs193p/cgi-bin/index.php" rel="nofollow noreferrer">iPhone dev courses</a> from Stanford Open-University, and I've been blocked for 2 days on <a href="http://cs193p.stanford.edu/downloads/Assignment3.pdf" rel="nofollow noreferrer">assignment3</a>, maybe someone can help me here?</p>
  
  <p>The tasks are:</p>
  
  <ol>
  <li>Create a custom UIView subclass that will display your PolygonShape object </li>
  <li>Give your view class access to the PolygonShape object so that it can retrieve the details of the polygon as needed </li>
  </ol>
  
  <p>The problem is: <strong>how do I give my view class access to the polygon object defined in my controller?</strong></p>
  
  <p>Here is my implementations if it can help:</p>
  
  <p>CustomView.h:</p>
  
  <pre><code>#import "PolygonShape.h"
  
  @interface CustomView : UIView {
      IBOutlet PolygonShape *polygon;
  }
  - (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides;
  
  @end
  </code></pre>
  
  <p>Controller.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;Foundation/Foundation.h&gt;
  #import "PolygonShape.h"
  #import "PolygonView.h"
  
  @interface Controller : NSObject {
      IBOutlet UIButton *decreaseButton;
      IBOutlet UIButton *increaseButton;
      IBOutlet UILabel *numberOfSidesLabel;
      IBOutlet PolygonShape *polygon;
      IBOutlet PolygonView *polygonView;
  }
  - (IBAction)decrease;
  - (IBAction)increase;
  - (void)awakeFromNib;
  - (void)updateInterface;
  @end
  </code></pre>