• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: setNeedsDisplayInRect not triggering drawRect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setNeedsDisplayInRect not triggering drawRect?


  • Subject: Re: setNeedsDisplayInRect not triggering drawRect?
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 4 Sep 2009 12:38:24 -0700

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: setNeedsDisplayInRect not triggering drawRect?
      • From: Michael de Haan <email@hidden>
References: 
 >setNeedsDisplayInRect not triggering drawRect? (From: Michael de Haan <email@hidden>)
 >Re: setNeedsDisplayInRect not triggering drawRect? (From: Quincey Morris <email@hidden>)
 >Re: setNeedsDisplayInRect not triggering drawRect? (From: Michael de Haan <email@hidden>)

  • Prev by Date: Re: setNeedsDisplayInRect not triggering drawRect?
  • Next by Date: Re: setNeedsDisplayInRect not triggering drawRect?
  • Previous by thread: Re: setNeedsDisplayInRect not triggering drawRect?
  • Next by thread: Re: setNeedsDisplayInRect not triggering drawRect?
  • Index(es):
    • Date
    • Thread