Does anyone know how to use line breaks in NSString? I need to do something like this -
[NSString stringWithFormat:@\"%@,\\n%@\", mystring1,mystring2];
try this ( stringWithFormat has to start with lowercase)
[NSString stringWithFormat:@"%@\n%@",string1,string2];
I just ran into the same issue when overloading -description for a subclass of NSObject. In this situation I was able to use carriage return (\r) instead of newline (\n) to create a line break.
[NSString stringWithFormat:@"%@\r%@", mystring1,mystring2];
In Swift 3, its much simpler
let stringA = "Terms and Conditions"
let stringB = "Please read the instructions"
yourlabel.text = "\(stringA)\n\(stringB)"
or if you are using a textView
yourtextView.text = "\(stringA)\n\(stringB)"
Line breaks character for NSString is \r
correct way to use [NSString StringWithFormat:@"%@\r%@",string1,string2];
\r ----> carriage return