Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Keep white spaces when saving UITextView text

lukeirvinlukeirvin Posts: 388Registered Users @ @
edited June 2015 in iOS SDK Development
I'm saving text from a UITextView to NSUserDefaults but when it saves all the white space is trimmed. I'd like to keep it as is.

For example, I want the output to look as typed, such as:
I am a brown fox.

I can run fast.

Blah blah blah.
Here's my code for saving:
[[NSUserDefaults standardUserDefaults] setObject:self.myTextView.text forKey:@"myTextView"];
[[NSUserDefaults standardUserDefaults] synchronize];

Here's my code for output:
NSString *outputString = [[NSUserDefaults standardUserDefaults] stringForKey:@"myTextView"];
Here's how the output looks:
I am a brown fox. I can run fast. Blah blah blah.
It goes from 3 paragraphs to one.

Replies

Sign In or Register to comment.