Q:

How to convert any string text into plain-text format in objective-c

I am working on a chat application. When I copy text from anywhere and paste it into my text field, I want the text to be stripped from whatever font, size, color, etc. So it's in a default/plain-text format. Then I want to set my own, text style before sending the text.
Tried using NSPlainTextDocumentType but that didn't work.
UIFont *font = [UIFont fontWithName:@"GothamRounded-Bold" size:14];
text = [self.messagesTextView.text setFont:font];
text = NSPlainTextDocumentType;

Expect the text to be converted to plain-text format and then have the GothamRounded-Bold size:14 style added to it.

A:

I wonder if you're running into this problem...
By default, pasting formatted / rich text into a text field will not keep the formatting. It will be pasted as plain-text, and will be displayed with the font you've set for your field.
Try a test. Copy and paste this next line into your text field:
This should lose formatting.
Then try copy/paste with this line:
 should  formatting.
The first test line uses html tags. If you inspect the source, it should look like this:
<strong>This</strong> should <strong><em>lose</em></strong> formatting.

The second test line, however, uses unicode characters, and if you inspect the source it will look just like it looks here in this answer.
If that is what you're seeing, there is no (easy) way to "remove" the formatting, because there is no formatting.
It's much the same as if the user pastes an emoji, such as -  - into your text field.

