0

I'm currently working in Xcode with objective-c.

I have an normal NSString with a string. Let's say the string is "Hello Stackoverflow". Now I want to make the "Hello" piece of the string superscript, how do I do that?

UPDATE:

I want to display it in a UItextview. I tried kCTSuperscriptAttributeName from the other post, but the UItextview won't allow "NSmutableattributedstring" or "NSattributedstring".

  • 1
    A casual NSString does not support such functions. You need an NSAttributedString. Please see the following http://stackoverflow.com/questions/8555735/how-to-make-subscripts-and-superscripts-using-nsattributedstring – geo Aug 22 '14 at 13:35
  • `NSString` has no notion of formatting. Are you trying to display this string in e. g. a `UILabel` or `UITextView`? Then you could use `NSAttributedString`. – The Paramagnetic Croissant Aug 22 '14 at 13:35
  • Where are you displaying your `NSString`? – Neeku Aug 22 '14 at 13:48
  • I want to display it in a UItextview. –  Aug 22 '14 at 17:01

1 Answers1

-1

Well you can't as NSString only holds characters, not attributes about how those characters will be displayed.

That answers the question, however my answer can be enhanced if you tell us how you intend to display the string.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242