The documentation for stringByTrimmingCharactersInSet states:
Returns a new line, executed by deleting from both ends that are contained in the specified character set.
In other words, it only removes offensive characters before and after the line with any valid characters. Any โoffensiveโ characters remain in the middle of the line, because the trimming method does not apply to this part.
In any case, there are several ways to do what you are trying to do (and @Narayana's answer is good too ... +1 to him / her). My solution would be to set your string s as mutable string and then do:
[s replaceOccurrencesOfString: @" " withString: @"" options: NSBackwardsSearch range: NSMakeRange( 0, [s length] )];
source share