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

1.去除首尾空格:

NSString * content = [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

2.去除首尾空格和换行:

NSString *content = [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

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