Remove characters from NSString?

Raju picture Raju · May 29, 2009 · Viewed 141.5k times · Source
NSString *myString = @"A B C D E F G";

I want to remove the spaces, so the new string would be "ABCDEFG".

Answer

Tom Jefferys picture Tom Jefferys · May 29, 2009

You could use:

NSString *stringWithoutSpaces = [myString 
   stringByReplacingOccurrencesOfString:@" " withString:@""];