1. 공백과 탭 제거(whitespaceCharacterSet)
NSString *newString = [oldString stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
 
2. 공백과 탭 및 개행(newlines) 제거(whitespaceAndNewlineCharacterSet)
NSString *newString = [oldString stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];

반응형