Drawing many different strings quickly
Drawing many different strings quickly
- Subject: Drawing many different strings quickly
- From: Ben <email@hidden>
- Date: Sun, 27 Sep 2015 18:42:02 +0100
Hi list,
I'm needing to draw somewhere in the order of 1,000,000 different strings in a scrollable grid view and am struggling to get performance that I am happy with.
After profiling, most of my time is spent in drawing text into the view.
My first attempt was simply to use NSString's drawInRect:withAttributes:. The attributes dictionary was cached between calls. This is not too bad for shorter strings, but slows down dramatically once longer strings need to be drawn truncated.
My second attempt has been to use my own NSTextStorage/Container/LayoutManager trio and draw using NSLayoutManager. This is faster when many strings are the same, but worse when most are different. I don't know in advance what the strings will be so must assume they are all unique.
Can anyone suggest what I should look into next? My requirements are as follows:
- Assume around a million unique strings to be drawn
- Not all strings to be drawn at once, a scroll view is being used and I am using responsive scrolling to pre-draw areas. The problem occurs when quickly scrolling a large distance
- Longer strings will be truncated to a single line under 200px wide
- All strings to be drawn in the same font/size/colour
- I can target the current (or current+1) OS version if that makes any difference
Any pointers or suggestions gratefully accepted!
- Ben
_______________________________________________
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