objective-c - 从 NSString 中删除字符?

NSString *myString = @"A B C D E F G";

我想删除空格,所以新字符串是“ABCDEFG”。

最佳答案

你可以使用:

NSString *stringWithoutSpaces = [myString 
   stringByReplacingOccurrencesOfString:@" " withString:@""];

https://stackoverflow.com/questions/925780/

相关文章:

objective-c - 如何获取 Root View Controller ?

iphone - 是否有记录的方法来设置 iPhone 方向?

ios - UIFont - 如何获取系统细字体

objective-c - NSAutoreleasePool 自动释放池是如何工作的?

ios - TabBar 图像的大小应该是多少?

objective-c - 容器 View Controller 示例

objective-c - 使用 NSPredicate 根据 NSDictionary 键过滤 N

iphone - iOS:在代码中访问 app-info.plist 变量

iphone - "wait_fences: failed to receive reply: 10

ios - 比较两个 CGRect