On Sep 4, 2009, at 12:23, Michael de Haan wrote:

(For simplicity, I implement an "int state" ivar to which drawRect refers)


In init, this:

- (id)initWithFrame:(NSRect)frame {
   self = ........
                [self setCurrentColor:[NSColor yellowColor]];
                [self setState: 1];
         .........
}



Here is the relevant code in drawRect;

        static int status = 0;
        if (status == 0)
        [ [self currentColor] set];
        else if ( status % 2)
                [[NSColor blackColor]set];
        else
                [[NSColor blueColor]set];
        status +=1;

But this drawRect code doesn't use a "state" ivar, it uses a static variable "status", so setState: won't ever affect drawRect.

1) Even though, as Quincey alluded to, I would have expected the outlet "view" and self to be equivalent, they are not. It seems as if "self" to changeViewDelta is a different entity from the outlet "view".

Ah, that's a different kettle of fish. It sounds like you've created 2 view instances by mistake. Because you've got an 'initWithFrame', the implication is that you are creating the view in code ('[[MyView alloc] initWithFrame: frame]' somewhere). Because you've got a "view" outlet, the implication is that you have a custom view object in a XIB file.

Those are two different view objects. If that's what you've got, you need to choose one technique or the other.


_______________________________________________

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