NSString 删除换行符 (Objective-C)

NSString remove line breaks (Objective-C)

我正在将数据从 XML 加载到我的 NSString,但数据格式如下:

    Lorem ipsum dolor sit amet, 
    consectetur adipiscing elit. 
    Sed a velit ut nulla tincidunt finibus sit amet sed felis. 
    Fusce quis quam sapien.

它有换行符,我怎样才能修改它,所以文本看起来像这样(全部在一行中):

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a velit ut nulla tincidunt finibus sit amet sed felis. Fusce quis quam sapien. Cras diam metus, viverra in urna sed, efficitur varius sem. Pellentesque accumsan, lectus at rutrum pulvinar, 

试试这个

NSString *newString = [[oldString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@" "];