2

When i parse the jason url i got string with character \n \r ... Now i want break the line where with "\n" and put the paragraph with "\r".

i got string like this.

description = "Black Chasm Cavern was designated a National Natural Landmark by the National Park Service in 1976 after being recommended by local members of the National Speleological Society, and as such is considered a \"nationally significant natural area.\U201d\n\nVisitors to the cave are enchanted by the beauty of a wide variety of formations including stalactites, stalagmites, flowstones and the vast arrays of rare helictite crystals, for which Black Chasm is justly famous.\n\nThe 45-minute walk tour follows a series of platforms, stairs and walkways designed to give the best views of the cave without compromising the naturally pristine environment. Currently, the tour culminates in a visit to the Landmark Room, the location of the greatest collections of sparkling helictite crystals.\n\nAbove ground, kids love our gemstone mining at our mining flumes right outside the Visitors Center. Everyone is guaranteed to find some real gemstones; the perfect start to a rock collection! Try our new incredibly popular geode cracking too!";

and i want to display this string in label as per format.

how can i do this job if any one have any idea please tell me ...

Thanks.

Raj
  • 1,213
  • 2
  • 16
  • 34
  • 1
    i want to do similar like this "http://stackoverflow.com/questions/2312899/how-to-add-line-break-for-uilabel"... – Raj Oct 31 '11 at 09:12
  • 1
    If u want to do similar to that then follow the accepted answer. – Baby Groot Oct 31 '11 at 09:54
  • 1
    i solved my problem form http://stackoverflow.com/questions/2312899/how-to-add-line-break-for-uilabel Thanks. – Raj Oct 31 '11 at 09:58
  • Just you have to set label.numberOfLines = 0; use your string as it is ... – Ankur Oct 31 '11 at 11:13

1 Answers1

1

I would suggest iterating through your string, separating it into an array of lines and paragraphs. Like the following.

NSArray *lines = [string componentsSeparatedByString:@"\n"];
for(NSString *line in lines)
{
NSArray *lineElements = [line componentsSeparatedByString:@"\r"];
// do something with lineElements
}
garyamorris
  • 2,587
  • 2
  • 17
  • 23