Performance: Drawing hundreds of short text strings
Performance: Drawing hundreds of short text strings
- Subject: Performance: Drawing hundreds of short text strings
- From: Mark Coniglio <email@hidden>
- Date: Mon, 20 Dec 2010 10:22:28 +0100
My application needs to draw hundreds of short
text strings into an NSView. After reviewing the
Cocoa documentation on drawing text, I am left
unsure as to how to do this with the highest
level of efficiency.
The text I am drawing will all be the same font
and font size and style; the color may vary
however. Taking advantage of the fact that the
font size/style is invariant would seem to be a
useful thing to do.
The text is not tabular; the starting point for
each string could be anywhere within the view. We
could say, for purposes of discussion, that the
origin for each chunk of text are, in essence,
"random".
Using the NSString "convenience functions" would
not seem the best route since the documentation
says "These methods are designed for drawing
small amounts of text or text that must be drawn
rarely. They create and dispose of various
supporting text objects, including
NSLayoutManager, every time you call them."
(Reference:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextLayout/Tasks/DrawingStrings.html)
Using NSCell seems a good alternative because
they are "lightweight". But in the same document
cited above, it says "for the most efficient
display of an arbitrary text string, use
NSLayoutManager directly." But since
NSLayoutManager seems to want to deal with a
single NSTextContainer as it's source, this
somehow doesn't seem to be a good solution for my
problem.
Any guidance regarding the method that will give
me the highest performance would be most
appreciated.
Thanks in advance,
Mark
--
_______________________________________________
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