How to print a string in a proper format if my string is having new line character in objective c
I am having an issue with this piece of code:
NSStri开发者_运维问答ng *msg=[[TBXML valueOfAttributeNamed:@"msg" forElement:root] ];
lblText.text=msg;
The variable msg
contains the string "Good Job\nThanks"
. When I assign 'msg' to the label text property, the string is shown with the newline character \n
but I would like the string to be displayed like this instead:
Good Job
Thanks
/shivam
As your string seems to come from a XML file, try to enter the XML's New Line character
instead of \n
. Otherwise it will print the characters \
and n
.
Try to set number of lines that label could have to unlimited number:
UILabel *label;
label.numberOfLines = 0;`
精彩评论