Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using nsattributedstring and nslocalizedstring

My old code uses NSLocalizedString to display the following where outputText was an NSMutableString that contained many such lines in a single output session:

[outputText appendFormat: NSLocalizedString(@"\n\n%@ and %@ are identical.  No comparison required.", @"\n\n%@ and %@ are identical.  No comparison required."), self.ipAddress, secAddress.ipAddress];

I'm trying to change the color of the various ipAddress strings, but can't find a similar method when using NSMutableAttributedString.

The biggest problem I'm facing is that since this entire string will be localized, I can't reliably set the NSRange without breaking up each part of the formatted output.

Do I need to dissect each part of this string, convert it to NSAttributedString and append each piece to the outputText??

like image 457
Mickey Avatar asked Nov 30 '12 13:11

Mickey


1 Answers

The answer is: yes.

Yes, you need to localize sections with different attributes separately.

like image 200
Cocoanetics Avatar answered Oct 17 '22 10:10

Cocoanetics