I want to ask a question about the NSString * in objective C. I have an string read from somewhere and I would like to get the last char of that NSString object? I used to try the objectAtIndex, but I don't know what to get the index. What should I type? Thank you very much.
unichar lastChar = [yourString characterAtIndex:[yourString length] - 1];
or if you want it as an NSString
:
NSString *lastChar = [yourString substringFromIndex:[yourString length] - 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