I am creating a calculator app and the calculator screen is a UILabel. I am having trouble with a delete key. Here is my Code:
.h
IBOutlet UILabel *display;
.m
- (IBAction)Del
{
[display.text substringToIndex:display.text.length -1];
}
it has no errors and runs in the simulator perfectly but does not actually work. Can anyone help.
You are ignoring the return value of the
substringToIndex:method and you do not update the label’s text.You want something like this:
This also guards against trying to delete from an empty label.