I have a NSString
like this:
Hello World of Twitter Lets See this >
I want to transform it to:
Hello World of Twitter Lets See this >
How can I do this? I'm using Objective-C on an iPhone.
Secondly, in Swift String is a struct, while in Objective-C, NSString is a class and inherit from NSObject . In concept, Swift String is more likely immutable. If we use a struct type and constant (remember the let keyword), we can keep out a lot of consideration of multi-thread programming and make us a better life.
Split the string into components and join them by space:
NSString *newString = [[myString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] componentsJoinedByString:@" "];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With