xcode cut last characters from string

DennisW83 picture DennisW83 · Apr 19, 2011 · Viewed 20.2k times · Source

I am working on a Xcode program and need to cut the last 5 characters from a string.

Does anybody know how to cut the last 5 characters from a NSString?

Answer

Philip Kramer picture Philip Kramer · Apr 20, 2011

just looked for it my self few minutes ago

NSString *str = @"1234567890";
NSString *newStr;

newStr = [str substringToIndex:[str length]-5];

NSLog(@"%@", newStr);