1

Is it possible to have exponents in an NSString object that will be displayed in a UITextField and a UILabel? If so, how do we do it? If not, any alternatives you might suggest?

Alex
  • 451
  • 5
  • 13

1 Answers1

3

As answered by jrturton in this question:

You need to include the unicode symbol for a superscripted character:

NSInteger number = 10; 
NSString *cubedSymbol = @"\u00B3";
NSString *tenCubed = [NSString stringWithFormat:@"%d%@",number,cubedSymbol];

Plenty more fun is to be had here

Community
  • 1
  • 1
Paul Woidke
  • 928
  • 4
  • 18
  • 40
  • that would work, is there a way to write whatever number i want in superscript? – Alex Jan 23 '13 at 21:52
  • From what I can find, it sounds like it's possible but not as easy. Check out [this question](http://stackoverflow.com/questions/5080175/how-to-create-subscript-characters-thats-not-in-unicode-in-ios) and [this question](http://stackoverflow.com/questions/6062696/display-superscript-using-nsnumberformatter) for the specifics. – Paul Woidke Jan 23 '13 at 21:56