---
title: "Cocoa库中移除字符串前后空白的方法"
author: "yvfeng"
date: "2011-12-19T15:13:00Z"
tags: ["Objective-C", "iOS", "iPhone", "trim"]
categories: ["移动开发"]
slug: "cocoa"
draft: false
lastmod: "2011-12-19T15:13:36Z"
id: 1316830
url: "https://yvfeng.iteye.com/blog/1316830"
---

```
NSString *str = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
```