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?
Asked
Active
Viewed 1,041 times
1
-
Are you talking about superscript? – DuckMaestro Jan 23 '13 at 21:49
-
Yes superscript would be perfect! – Alex Jan 23 '13 at 21:51
-
Check this answer http://stackoverflow.com/a/12813254/1730272 – iDev Jan 23 '13 at 22:04
-
thanks, i was looking for something like that! – Alex Jan 24 '13 at 03:03
1 Answers
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