除开NSString中空格

去掉NSString中空格NSString *s @this isastringwith lotsofwhite space NSArray *comps [s compon

去掉NSString中空格

NSString *s = @"this is    a  string    with lots  of     white space"; NSArray *comps = [s componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];  NSMutableArray *words = [NSMutableArray array]; for(NSString *comp in comps) {   if([comp length] > )) {     [words addObject:comp];   } }  NSString *result = [words componentsJoinedByString:@" "]; 

?