从NSString中删除换行符 [英] Removing new line characters from NSString
本文介绍了从NSString中删除换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 NSString
,如下所示:
Hello
World
of
Twitter
Lets See this
>
我想将其转换为:
Twitter的Hello World让我们看到这个>
Hello World of Twitter Lets See this >
我该怎么做?我在iPhone上使用Objective-C。
How can I do this? I'm using Objective-C on an iPhone.
推荐答案
将字符串拆分为组件并按空格连接:
Split the string into components and join them by space:
NSString *newString = [[myString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@" "];
这篇关于从NSString中删除换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文