On Wed, Apr 15, 2009 at 9:55 AM, Graham Cox <graham....@bigpond.com> wrote:

> It's not illegal, though many will tell you it's not best practice

  To elaborate: According to the documentation (and good sense),
-drawRect: should be as quick / lightweight as possible since it could
be called many times in rapid succession (especially when resizing and
animating).

  If you have many strings to draw, you might try creating them all in
one go outside -drawRect: and storing them in a cache. Then -drawRect:
needs only to walk the cache and draw the strings. I also like to
cache string attributes (if they don't change / don't change
frequently), as they're a pretty complicated structure (a dictionary
containing attributes/values, and possibly an NSParagraphStyle which
is even more weight).


> Suggest you show the whole of drawRect:?

  ... as well as what you've found in the debugger (ie, the runtime
error and the line that's causing the problem).

--
I.S.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to