>Lesson: Don't change model data in a -draw method.  I really can't think of 
>any reason why you'd want to do this.   -draw is for drawing.

Yes, perhaps, but I have to change it, perhaps not in a draw method
itself, but in another method that get's called before it. In my real
program I have one, let's call it, MAIN object that has a draw method
and within it, it calls to draw methods of all its input objects:

    NSSet * myInputs = [self inputs];

    int inputCount = [myInputs count];

    if (inputCount != 0) {

        int n = 0;

        for (KRSimInput * input in myInputs) {

            [input setLocationX: ([self locationX] + ([self width] /
inputCount) * n++ + ([self width] / 2) / inputCount) - ([input width]
/ 2)];
            [input setLocationY: ([self locationY] - [input height] -
[input strokeWidth])];

            [input draw];

        }
    }

As you can see, before I can -draw an input I have to position it
right above the MAIN object. This position, as you can see from the
code, depends on inputCount and n, the current index. So I can't avoid
setters in -draw. Any suggestions?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to