I should have known this from my experience in Flash!  The solution to why it only draws the first polygon is that the same buttons, Increase and Decrease, required multiple, in this case 2, actions, not just one.  Basically you need to define another method, inside the polygonview, which calls setNeedsDispaly.  And hook up the same buttons in the nib file to that method.


  • Hirad

    I’m assuming you’re talking about the issue where the first polygon is drawn and then it doesn’t update with the increase/decrease buttons? If so, that’s because the instance of PolygonShape (or whatever your basic polygon class is) is different in the controller than it is in the view. You’re implementing all those increase/decrease methods again for a different instance. I did it by making the instance in the view a property and setting it to the controller’s instance, but what I really want to know is how I can make them the same instance. I tried connecting the view’s PolygonShape class in IB to the same PolygonShape class that the controller was hooked up to but they were still different instances.

    • marskoko

      Hirad, actually the post is an answer to why it wasn’t working. I figured it out; basically I just wasn’t updating the viewcontroller via setNeedsDisplay. My buttons updated the model thru the increase/decrease methods but didn’t call the setNeedsDisplay method of drawRect and that’s what I was missing in my code.

Leave a Reply