最近在项目中遇到了处理字符串前后空格的问题,防止以后忘记,在这里简单记录一下
NSString *str = @" 字符 ";
//去空格和回车
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
str = [str stringByTrimmingCharactersInSet:set];
NSString *str = @" 字符 ";
//去空格和回车
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
str = [str stringByTrimmingCharactersInSet:set];