iOS 去除字符串空格和换行符

NSString *  string=[countString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];//去除首位空格

NSString *  string = [countString stringByReplacingOccurrencesOfString:@" "withString:@""];//去除中间空格

NSString *  string =[countString stringByReplacingOccurrencesOfString:@"\n"withString:@""];//去除换行符

你可能感兴趣的:(iOS 去除字符串空格和换行符)