一、
NSString *str = @"sdjflkjdf sdf yiuo ";
str = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
二、
-(NSString*)trimString:(NSString*)str
{
NSMutableString *mstr = [str mutableCopy];
CFStringTrimWhitespace((CFMutableStringRef)mstr);
NSString *result = [mstr copy];
[mstr release];
return [result autorelease];
}