ios - How to put line breaks on strings Objective-C -
If I have a string in Objective-C which is actually long, such as:
NSString * text = [NSString stringWithFormat: @ "% @", _sometext]; How can I scan _sometext and add a line break to every hundred letter (letter) string? So if I had _sometext like it was November. Although it was not too late, when I turned to Londres Street then the sky was dark. Father had finished for the day, stopped the lights of the shop and closed the shutter; But so I will not come home in the dark which he left on the stairs with light on the flat.
How can I make it so that it will bring a line break
It was November. Although it was not too late, when I turned to Londres route
and after that
Father had finished for the day, stopped the lights of the shop and closed the shutter; But so I wo
(because they were 100 characters)?
But instead of closing in the middle of the word, I can leave this word and end in example in the previous word: if the sentence ends on " this happens" and The word "wish" was cut, then instead of " but therefore i " it must be stopped
The easiest way I can think from above my head is a two step process.
The phase involves breaking the original string into an array of 100 character strings.
Phase 2 includes joining that array of stars with the new line.
NSMutableArray * line = [NSMutableArray array]; While ([original string length]> 100) {[Lineod object: [originally stringedindexed: 100]]; Original string = [original string substringFromIndex: 100]; } [Lines addObject: original string]; NSString * reformattedString = [lines of components combined breasting: @ "\ n"];
Comments
Post a Comment