Qustion about possibly bad advice in NSView documentation
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