• 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: Optimizing NSView's drawRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimizing NSView's drawRect


  • Subject: Re: Optimizing NSView's drawRect
  • From: Markus Hitter <email@hidden>
  • Date: Thu, 24 Nov 2005 10:36:31 +0100


Am 24.11.2005 um 05:00 schrieb David Chan:

I have got a NSView which basically draw a shelf with books a la delicious
library. I provide the zooming function for user using NSSlider and user can
also resize the window. I notice that after zooming in and out, resizing
windows and scrolling up and down for a while, my program would tend to slow
down and sort of hang a bit, though it never crashes so far. It also take
considerably longer time to close upon quitting.

Others already explained how to hunt down performance bottlenecks and memory leaks.


I have untick the 'continuously send action while sliding' option from
NSSlide to lessen the call for redrawing on zooming but when it comes to
resizing window and scrolling, there is nothing I can do- drawRect seems to
get called numerous times as user scroll.

One thing you can do is to draw a quick outline in -drawRect only, then set a timer to do the rest after some 0.5 seconds. "Refresh" the timer on each -drawRect invocation, invalidate (fire immediately) it on a mouse up event. This should give you a smooth user experience.


And my drawRect is inevitably a costly method to call as I would have to
travel through my array of book collection, defining the coordinate and draw
it one by one.

Cache the coordinates as they change with a change in your collection, only?



Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Optimizing NSView's drawRect (From: David Chan <email@hidden>)

  • Prev by Date: Mixing cocoa and carbon crashing in photoshop plugin
  • Next by Date: Bundle question..
  • Previous by thread: Re: Optimizing NSView's drawRect
  • Next by thread: Re: Optimizing NSView's drawRect
  • Index(es):
    • Date
    • Thread