简体   繁体   English

如何从NSMutableString中删除最后一个字符

[英]How to remove the last character from an NSMutableString

Iam adding some text content to nsmutablestring in the form of dictionary format and again that every dictionary is split by ","(commos). 我以字典格式的形式向nsmutablestring添加了一些文本内容,并且每个字典都被“,”(commos)拆分。 But when getting this total string its displays (,) to string of ending. 但是当获得这个总字符串时,它显示(,)到结束字符串。 So how to remove that ","(commos) in that mutable string. 那么如何删除那个可变字符串中的“,”(commos)。

Please guide me if any one knows 如果有人知道,请指导我

Thanking in advance 提前感谢

This is how you need to remove character from NsmutableString.... 这是你需要从NsmutableString中删除字符的方法....

NSRange range = NSMakeRange([concatedstring length]-1,1);
[concatedstring replaceCharactersInRange:range withString:@""];

这样做,你保持字符串的mutable属性:

[mutableString setString:[mutableString substringToIndex:[mutableString length]-1]];

要删除字符串的最后一个字符,您可以编写:

string = [string substringToIndex:[string length] - 1];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM