Re: Qustion about possibly bad advice in NSView documentation
Re: Qustion about possibly bad advice in NSView documentation
- Subject: Re: Qustion about possibly bad advice in NSView documentation
- From: Matt Neuburg <email@hidden>
- Date: Wed, 26 Sep 2007 11:29:03 -0700
- Thread-topic: Qustion about possibly bad advice in NSView documentation
On Tue, 25 Sep 2007 07:08:43 -0700 (PDT), Erik Buck
<email@hidden> said:
>The conceptual documentation for NSView contains the following note:
>
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Subcla
ssingNSView/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:
The docs are not necessarily telling you to use setNeedsDisplayInRect as the
selector of performSelector. They are telling to use delayed performance as
a way of generating the setNeedsDisplayInRect call. So, for example
(pseudo-code follows):
- (void) drawRect: ... {
...
[self performSelector:@selector(setUpMoreRects:)
withObject:somethingOrOther afterDelay:0.1];
...
}
- (void) setUpMoreRects: (id) somethingOrOther {
... // maybe decode somethingOrOther if that's where the rects are
[self setNeedDisplayInRect:...];
}
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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