I need to compare 2 numeric strings in iOS. The first string, stored
, is a fixed long number, and I want to check that the last digit of the second string entered
is the same as the corresponding digit on the stored
string (which isn't necessarily the last digit).
For example...
entered = 123456789
stored = 12345678902345678
In this example, I'd like to check that 9
on entered
is the same as the digit in the same position on stored
.
I'm thinking there's 2 possible ways of achieving this, but if there's a simpler way that'd be great...
- Check the
entered
stringlength
and compare the character at that position ofentered
andstored
. - Check if the
entered
string is equal to the value of the correspondinglength
instored
.
Could someone please offer some advice in this area.