How does one remove the last character from an NSMutableString?
(string. length>0) returns 0 thus making the code return: string = [string substringToIndex:string. length-0];
We have removeChar() method that will take a address of string array as an input and a character which you want to remove from a given string. Now in removeChar(char *str, char charToRemove) method our logic is written.
You could use deleteCharactersInRange:
NSMutableString *str = [NSMutableString stringWithString:@"FooBarx"]; [str deleteCharactersInRange:NSMakeRange([str length]-1, 1)];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With