Remove spaces from a string
This can be accomplished with simple string formatting. Here's an example:
NSString *s = @"0800 444 333";
NSString *secondString = [s stringByReplacingOccurrencesOfString:@" " withString:@""];
See the NSString Class Reference for more details and options.
To further simplify, this line can also be written like this:
NSString *s = [@"0800 444 333" stringByReplacingOccurrencesOfString:@" " withString:@""];
if You want to remove white spaces at start and end the you usestringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]
string method.
For eg.
NSString *s = @"0800 444 333";
s = [s stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
And for removing all spaces answer by @NSPostWhenIdle is enough.