If I have a string that I am going to load into a TextField how can I make a line break \n occur every 10 characters (including spaces and whatnot) but not go to the next line mid-word… Like wrap the text with a max of 10 characters? But I’m not just wrapping in a UITextField I actually need the \n’s entered because it will be used in something else as well… (This is for iOS if that matters) any help is appreciated I’m really stuck!
Share
You might want to make use of NSScanner in a loop to put together this kind of thing, but to figure out the precise algorithm you’d need to clarify exactly how you want it to work. Here are questions that you would need to answer:
With these assumptions about your problem in mind, I would code it like this: