Extracting from the right of a string in objective C <p>This seems to be what I'm looking for but in reverse. I would like the <code>string</code> to extract from the right not from the left. The example extracting from the left is given:</p> <pre><code>NSString *source = @"0123456789"; NSString *firstFour = [source substringToIndex:4]; Output: "0123" </code></pre> <p>I'm looking for a version of the below that works from the right (what is below doesn't work)</p> <pre><code>NSString *source = @"0123456789"; NSString *lastFour = [source substringToIndex:-4]; Output: "6789" </code></pre> <p>the <code>[source substringFromIndex:6];</code> won't work because sometimes I will get an answer that is 000123456789 or 456789 or 6789. In all cases I just need the last 4 characters from the string so that I can convert it to a number.</p> <p>there must be a better way than a bunch of if else statements?</p>