- 去除首尾空格
NSString *title = [title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- 去除首尾換行
NSString *title = [title stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
- 去除首尾空格和換行
NSString *title = [title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
摘自:https://blog.csdn.net/zhoupengju/article/details/52168926