Preface
Today, I came across a requirement that a string of strings returned from the background is @ “1, Hello, how are you in the new year; 2, how are you in the new year; 3, how are you in the new year.” this is how you put it in the sealed alert prompt box.
The requirement of optimization is to display the new line in the format of the alert box.
Resolvent
Just now, the idea is string splicing @ “\ n”. I took a detour at the beginning, because it is to encapsulate the alert, so I went to process the string in the alert when the string passed an alert. Later, I found that I couldn’t do it. When I spliced the @ “\ n”, nslog printed it out as a new line, but it was put back on the alert as it was before. Later, I found that I manually gave it to you. String can be divided by adding @ “\ n” to the string @ “Hello \ n hello”. When I was just writing and printing, the line was divided, but the string was not spliced to @ “\ n”, so alert is still the same as before. So later, I want to process this string from the beginning, take it directly to the string returned in the background, and then directly splice it. Common spelling If it doesn’t work, it’s still the same, @ “\ \ n”, \ n is spliced, but it doesn’t break the line, that is, simple characters are spliced into strings.
Later, I added a sentence that means replace, and then it will be OK.
Finally, I optimized the for loop array to delete directly. Finally, I added a judgment, if the background returned Chinese “;” or English “;” or no time.
A rookie, originally quite a simple optimization, and finally what about Baidu? It took me half an hour to figure it out.
summary
The above is the whole content of this article. I hope that the content of this article has a certain reference learning value for everyone’s study or work. If you have any questions, you can leave a message and exchange. Thank you for your support for developepaar.