NSString* headerData=***;
headerData = [headerData stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去除掉首尾的空白字符和換行字符
headerData = [headerData stringByReplacingOccurrencesOfString:@"\r" withString:@""];
headerData = [headerData stringByReplacingOccurrencesOfString:@"\n" withString:@""];
如此即可。