I'm trying to get this code to work. But am at a loss as to why it does not.
The code does add the neg sign "-" if it's not there. But does not remove it if it's there. Please help as I'm trying to get my head around this as a hobby.
no warning it runs but just won't delete the "-"
The code does add the neg sign "-" if it's not there. But does not remove it if it's there. Please help as I'm trying to get my head around this as a hobby.
Code:
- (IBAction)NegPlus:(UIButton *)sender {
NSRange hasNegSing = [self.display.text rangeOfString:@"-"];
NSString *myDisplay = self.display.text;
if(hasNegSing.location == NSNotFound){
myDisplay = [@"-" stringByAppendingString: myDisplay];
self.display.text = myDisplay;
}
else {
NSLog (@"the mydisplay before = %@", myDisplay);
deleteCharactersInRange:[myDisplay rangeOfString:@"-"];
NSLog (@"the mydisplay after = %@", myDisplay);
}
Last edited by a moderator: