我的意思是我只需要删除 NSString 左边的空格
如果我有 "This is a good day"
我就会有 "This is a good day"
只有左边的空格
有什么建议吗
最佳答案
就用
NSString* result = [yourString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
它会移除左边和右边的所有多余空间,但不会移除中间的空间
并删除空格和 \n
使用
NSString* result = [yourString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
关于iphone - 删除 NSString 左边的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6278593/