Is there a way to get exact spacing of a text file to match the formatting in UI Text View?

My problem is, I have a text file, I use "text edit" on Mac to create the templates. I have all the fields laid out and it renders well on word, etc. When I read the file and display it in A Storyboard Text View window, all the spacing is off. I can manipulate it, and get it to render properly but when I do, the manipulations change the original file formats. I'm using objective C and I'm trying to find a way to simply have what I have in text file line up exactly as it does outside of iOS.
I appreciate any help. thanks so much

Replies

all the spacing is off

How are spacing defined in original text ? With space character ? With tabs ?

What do you get ? 3 spaces replaced by a single spacing ? Other ?

I've seen you answered this older thread. https://developer.apple.com/forums/thread/62515

Doesn't the solution you proposed work ?

  • thanks for the reply. See my solution below.

Add a Comment

The answer is "MONOSPACED". The first step was to try to understand exactly what the NSAttributedString model was. Then to add an attribute to the NSDictionary that is associated with the model. Placing Monospaced of some size and weight, it was able to get the Text Editor to match the alignment in Text View. I found this to be what I needed to do. [attributesDictionary setObject:[UIFont monospacedSystemFontOfSize:12 weight:20] forKey:NSFontAttributeName]; The documentation has a level of confusion in it such that I had to try for a week to understand how to manipulate the Attributes and apply them to "self.myTextView.attributedText". This story wasn't evident at first. Now I'm clear....Hopefully this helps someone