V
V
Vanya Ivanov2014-03-23 21:54:45
Objective-C
Vanya Ivanov, 2014-03-23 21:54:45

Objective-c - How to remove the last element of a string?

How to remove the last element of a string in Objective-C?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey1, 2014-03-23
@mr_cloud

If NSString then

NSString *str = @"test1";
  str = [str substringToIndex:[str length]-1];

If NSMutableString then
NSMutableString  *str = [NSMutableString stringWithString:@"test1"];
[str deleteCharactersInRange:NSMakeRange([str length]-1, 1)];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question