Trim spaces from end of a NSString

前端 未结 14 1150
既然无缘
既然无缘 2020-11-27 09:26

I need to remove spaces from the end of a string. How can I do that? Example: if string is \"Hello \" it must become \"Hello\"

14条回答
  •  孤城傲影
    2020-11-27 09:50

    NSString* NSStringWithoutSpace(NSString* string)
    {
        return [string stringByReplacingOccurrencesOfString:@" " withString:@""];
    }
    

提交回复
热议问题