Objective-c – Remove last character of NSString

nsstringobjective c

I've got some trouble 'ere trying to remove the last character of an NSString.
I'm kinda newbie in Objective-C and I have no idea how to make this work.

Could you guys light me up?

Best Answer

NSString *newString = [oldString substringToIndex:[oldString length]-1];

Always refer to the documentation:


To include code relevant to your case:

NSString *str = textField.text;
NSString *truncatedString = [str substringToIndex:[str length]-1];