I am trying to code a textField so that is someone put in the number 1 only it will show up 10 and if the put in the number 01 it will show up 01.
The problem I have is that when I code an if statement it can’t seem to read the 0 at the start of the number so I end up with 010 or just 1.
I have tried to use integers but get the same result and have tried == and compare for strings but nothing.
NSString *millieString = [[NSString alloc]initWithFormat:@"%@",timeFieldMillie.text];
if([millieString compare:@"01"]){
timeFieldMillie.text = [[NSString alloc]initWithString:millieString];
}
else if ([millieString compare:@"1"]){
timeFieldMillie.text = [[NSString alloc]initWithFormat:@"%@0", millieString];
}
This is probably because the first 0 is not being read but I can’t seem to fix it.
I am trying to make a time converter and this is for the milliseconds so I need it to be 2 digits long.
Thanks
-isEqualToString:insteadifHere’s a simpler version:
Or simply: