1

Possible Duplicate:
UILabels and Unicode

Is there a way to use math symbols in UILabels and UITextField just like the html ÷ × −, ° etc.?

1

2 Answers 2

2

Just drag the symbols from Mac OS X' Character Viewer to Xcode. Than it should look like

label.text = @"÷ × −, ° ";

No need to deal with codes or html-entities.

If you have html-entities in your text, this category might be helpful: GTMNSString+HTML

1
  • so how do i convert '÷'symbol pulled from within an array via NSURL? May 1, 2012 at 20:30
0

You can't use the HTML encodings, but you can embed the actual symbols directly into your code or your XIB files as Xcode treats Objective-C source files as Unicode / UTF-8.

To convert a string myHTMLString which has the encoded symbols, use

NSString* convertedString = [myHTMLString stringByDecodingHTMLEntities];

and use this NSString* category: (Just include "NSString+HTML.m" in your source) https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m

2
  • The array that i pulled from server via NSURL has symbols formatted in html unicode. Is there a way to search the strings within the array for these unicodes and replacing them with the equivalent Unicode in mac/xcode? May 1, 2012 at 22:27
  • Oh, well, in that case, - (NSString *)stringByDecodingHTMLEntities;
    – Tim
    May 2, 2012 at 23:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.