I have built an app where the user can press a button and get a number of text responses on each tap. After 10 responses, the button runs out of things to say, so I have a reset button placed so that the user can tap it and run the button method again. At this point I am just having trouble figuring out a method to do the reset.
@implementation ViewController
@synthesize billLabel, topLabel, bill;
- (void)viewDidLoad
{
[super viewDidLoad];
[bill setHidden:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)button:(id)sender
{
[bill setHidden:NO];
static int counter;
if (counter == 0)
{
billLabel.text = @"text";
}
else if (counter == 1)
{
billLabel.text = @"text2";
}
else if (counter == 2)
{
billLabel.text = @"text3";
}
else if (counter == 3)
{
billLabel.text = @"text4";
}
else if (counter == 4)
{
billLabel.text = @"text5";
}
else if (counter == 5)
{
billLabel.text = @"text6";
}
else if (counter == 6)
{
billLabel.text = @"text7";
}
else if (counter == 7)
{
billLabel.text = @"text8";
}
else if (counter == 8)
{
billLabel.text = @"text9";
}
else if (counter == 9)
{
billLabel.text = @"text10";
}
else if (counter == 10)
{
billLabel.text = nil;
}
counter += 1;
}
- (IBAction)reset:(id)sender
{
}
@end
Although your question is a little confusing, I believe I know what you are to do. Make your
int countera class level variable first. Be sure to declare it as 0 at that point. Then, in your reset method simply use this code,You may want to then disable the button, but that’s up to you.