• 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: String Allocation inside drawRect:...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String Allocation inside drawRect:...


  • Subject: Re: String Allocation inside drawRect:...
  • From: "I. Savant" <email@hidden>
  • Date: Wed, 15 Apr 2009 10:11:23 -0400

On Wed, Apr 15, 2009 at 9:55 AM, Graham Cox <email@hidden> 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 (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

References: 
 >String Allocation inside drawRect:... (From: Carlos Eduardo Mello <email@hidden>)
 >Re: String Allocation inside drawRect:... (From: Graham Cox <email@hidden>)

  • Prev by Date: filteredArrayUsingPredicate and points
  • Next by Date: Objective-C/Cocoa open source Twitter client
  • Previous by thread: Re: String Allocation inside drawRect:...
  • Next by thread: unrecognized selector sent to instance
  • Index(es):
    • Date
    • Thread