I am retrieving data from webservice like this
NSString *str_Txt = [rootElement stringValueForNode:@"info"];
NSLog(@"str_Txt is %@",str_Txt); // Data Receive
output:
str_Txt is \n\n\nInfo \n\n\nSebastian Vettel \n\n Alonso
I want when \n comes line will break
like this
textview.text = [NSString stringWithFormat:@"%@", str_Txt];
NSLog(@"textview is %@",textview.text);
output: // supposing output
textview is
Info
Sebastian Vettel
Alonso
but the problem is that the when i run that code output again come like this:
textview is \n\n\nInfo \n\n\nSebastian Vettel \n\n Alonso
Line is not breaking. \n is not working.
I want to do something like this:
// textview.text =@"\n\n\nInfo \n\n\nSebastian Vettel \n\n Alonso";
textview.text = @""%@",[NSString stringWithFormat:@"%@", str_Txt]";
NSLog(@"textview is %@",textview.text);
so that my output will shoe like this:
output: // supposing output
textview is
Info
Sebastian Vettel
Alonso
Any idea, how to do this?
Thanks in advance.
I think the text which you’re getting is showing you “
\n” and hence as Carl Norum mentioned, these are not new line character but normal literal string. You can try to replace the occurrence of “\\n” with “\n“.This should help you achieve what you’re trying to achieve.