Is there a setNeedsDisplay: NO not used at all?

In Cocoa, when we want to redraw the view, we would send view a setNeedsDisplay:telling the view to redraw itself using the YES parameter. I was wondering if there are any circumstances under which you want to send the view setNeedsDisplay:NO, for example, multi-threaded environments, and if you send the view a setNeedsDisplay:YES, and then install it again immediately after using the setNeedsDisplay:NOredrawing of the view itself. If there is no reason to call setNeedsDisplay:NO, then why create such a tedious method where they could instead implement something like[view redrawView]

+5
source share
2 answers

setNeedsDisplay:NOcan be used if you want to cancel the previously called setNeedsDisplay:YES. For instance. sometimes it’s easier to mark all subtasks as necessary for display, and then run the algorithm to undo some of them.

+1
source

As you may know, updating the display automatically (if necessary) at each pass through a regular event loop. You call setNeedsDisplay:to force refresh the display, if necessary.

From the documentation NSView:


, , , , setNeedsDisplay:. NSView, , . ( , , , , ...)

, , - "needsDisplay" true false. , setNeedsDisplay: "redrawView", .

Edit

:


, ; NO, , .

-2

All Articles