• 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
Qustion about possibly bad advice in NSView documentation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Qustion about possibly bad advice in NSView documentation


  • Subject: Qustion about possibly bad advice in NSView documentation
  • From: Erik Buck <email@hidden>
  • Date: Tue, 25 Sep 2007 07:08:43 -0700 (PDT)

The conceptual documentation for NSView contains the following note:
  http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/chapter_5_section_3.html

  "Note: The implementation of the NSView class before Mac OS X v10.4.3 could discard any rectangles marked as needing display within a subclass's implementation of drawRect:. For maximum compatibility, when marking areas as requiring display from within the drawRect: method it is best to call the view's setNeedsDisplayInRect: method using the NSObject instance method performSelector:withObject:afterDelay:."

  Um, isn't this supremely bad advice ? performSelector:withObject:afterDelay:. requires an _object_ argument.  How exactly is an NSRect structure going to be passed as the argument to performSelector:withObject:afterDelay:?

  I think the note should have stated, "don't call -setNeedsDisplayInRect: from within an implementation of -drawRect: because some versions of Mac OS X ignore changes to invalid areas from within -drawRect."  Even more advice would be "limit the code within an implementation of -drawRect: to code that actually draws.  Any other code such as application logic to determine what should be drawn is best implemented elsewhere because -drawRect: will be called automatically by Cocoa whenever a view needs to be drawn, and you may not be able to predict all of those times."

_______________________________________________

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: Qustion about possibly bad advice in NSView documentation
      • From: Dominik Pich <email@hidden>
  • Prev by Date: Re: Tight Runloop
  • Next by Date: Re: Qustion about possibly bad advice in NSView documentation
  • Previous by thread: Re: Tight Runloop
  • Next by thread: Re: Qustion about possibly bad advice in NSView documentation
  • Index(es):
    • Date
    • Thread