So I have an array that is filled in by parsing an XML file. In the file, there are lines that contain ‘\n’ for a next-line character.
When I try to display said lines
self.myTextView.text = _myString;
it displays in the simulator as
\nLorem \nipsum \ndolor \nsit \namet ....
(It prints the same way through console – However, if I manually set
self.myTextView.text = @"\nLorem \nipsum \ndolor \nsit \namet";
it will display as
Lorem
ipsum
dolor
sit
amet
Does anyone know how to work around this problem? Thanks in advance.
Your input string literally contains the characters
\nwhich have no special meaning outside of a C-compiler (or Java, or C++ or Objective-C, etc.).If you want the
\ncharacters converted to newlines then you need to do this yourself, perhaps using: