去除string首尾空格:
NSString *NewString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *NewString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
原文地址:http://blog.csdn.net/nt_tian/article/details/45172141