Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Why won't \n work in a string from a plist?

In swift, why is it that \n won't work when pulling a string from a plist to fill a UITextView?

3 Answers

I think it's because in the plist the data is Base-64 encoded and not Unicode

I don't think I follow your question. Could you give a small code example of your problem?

Sure Thanks,

This creates the path and an instance of my array= var myPath = NSBundle.mainBundle().pathForResource("NameOfMyPlist", ofType: "plist") var myArray = NSArray(contentsOfFile: myPath!)

I then want to fill myTextFieldView with a string from the array= myTextFieldView.text = myArray![1] as String

This works and fills the text field view.

The only problem is that if the string in the array looks like "my first line\nmy second line" it should display: my first line my second line

Instead it displays: my first line\nmy second line