I have an iOS
project using Xcode 7
and Swift3
. I have a UITextView
that enables the user to save that text via NSUserDefaults
into a String
variable. However, if the user has a lot of text that includes paragraphs, when they save the text, it compiles it together to be one big long string of text, not recognizing the original paragraphs.
How do I have the string of text in essence recognize there are paragraphs and then make them into separate strings that are part of a [String]
? Is this possible?
Example of text:
This is a complex task for me.
I don't know how to do this.
After the user names this text, which is two separate small paragraphs, it would save to NSUserDefaults
as:
This is a complex task for me. I don't know how to do this.
I know rather than save a String
to NSUserDefaults
I need to instead use a [String]
, but I still can't figure out how to take a UITextView
and convert it's text into the string array, separating each paragraph into a separate String
.