Can someone explain this code
- (IBAction)backspacePressed {
self.display.text =[self.display.text substringToIndex:
[self.display.text length] - 1];
if ( [self.display.text isEqualToString:@""]
|| [self.display.text isEqualToString:@"-"]) {
self.display.text = @"0";
self.userIsInTheMiddleOfEnteringNumber = NO;
}
}
I don’t get what the 2 lines mean in objective c. || Also, I don’t get the meaning of substringToIndex. How does a programmer know to use substringToIndex out of all the different methods in the documentation I saw substringFromIndex etc. There are so many. Is this saying that the strings in the index are counted and -1 means it deletes a string? How would the meaning in the apples documentation relate to deleting a character ?
Comments supplied with explanation of code…