Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

finicalrogue

macrumors newbie
Original poster
Jun 29, 2010
1
0
Sorry for being a newbie, Please help!

I am creating a fairly simple app that layers on iTunes, using its Apple Events stuff. That side is going well...

My Question is, my app, because it uses the strings of the currently playing Artists and Song Name etc. this could change rapidly in my case (less than every second, updates of the playing track strings can occur this fast) I was wondering what the most efficient way to draw to the strings with font attributes, background and also alignment...? I am looking to save some time too!

I tried passing NSAttributedStrings to TextFields (Set out as Labels in IB); fine for initial uploading of string, but with the constant updating, it obviously does not really enjoy it. I tried just using:

[trackDescriptionLabel setStringValue:description];

For example, but it looses all the formatting from the initial NSAttributedString. Is there anyway to lock these atributes and just change the text that is displayed?

I have tried implementing NSTextView classes also, however they do not seem to offer both, font, background color changes and alignment... I could be wrong! (there are a few deprecated methods and properties for example)

Any reply would be appreciated, I know how first posts can drown!!

Kindest Regards

James Hartt
 
How exactly are you getting and updating the currently playing information, and what do you mean by "does not really enjoy it"? Cocoa should be fine drawing 100s of strings a second, so that shouldn't be the problem, and leads me to believe the issue may be elsewhere.
 
http://developer.apple.com/mac/libr...a/Conceptual/CocoaDrawingGuide/Text/Text.html has information on this. Essentially, the NSAttributedString drawing methods are provided as a convenience, and aren't as fast for repeated drawing as doing things a bit more manually. In particular, consider the "Drawing Text with NSLayoutManager" section here: http://developer.apple.com/mac/libr...nceptual/TextLayout/Tasks/DrawingStrings.html


As always, use Shark and Instruments first to determine exactly what and where the performance issues are :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.