Reputation: 2793
in my app I'm taking into account the clicks made on a botton . The number of clicks is displayed in a label and I used this code ... I wish that the number of clicks started not from 0 but from 12 and stop automatically at 30. How can I give these blocks in my action where I draw the NSInterger ?
Thank you all for the help
@ interface FFDettagliEsami () {
NSInteger FFVariabileNumerica_CFU_Votazione ;
}
@ end
@ implementation FFDettagliEsami
- ( IBAction ) FFAddVotazione : (id ) sender {
FFVariabileNumerica_CFU_Votazione + + ;
[ FFVotazioneLabel setText : [ NSString stringWithFormat : @ " % d", FFVariabileNumerica_CFU_Votazione ]] ;
}
Upvotes: 0
Views: 49
Reputation: 25144
You can initialize FFVariabileNumerica_CFU_Votazione
to whichever value you want in places like viewDidLoad:
or initWith...
if it's a view controller.
And for stopping at 30, just add a check :
- (IBAction)FFAddVotazione:(id)sender {
if (FFVariabileNumerica_CFU_Votazione >= 30)
return;
FFVariabileNumerica_CFU_Votazione++ ;
[FFVotazioneLabel setText:[NSString stringWithFormat:@"%d", FFVariabileNumerica_CFU_Votazione]];
}
Upvotes: 1
Reputation: 1476
use
static NSInteger FFVariabileNumerica_CFU_Votazione = 12;
and in - ( IBAction ) FFAddVotazione : (id ) sender
add the condition to check for FFVariabileNumerica_CFU_Votazione < 30
if(FFVariabileNumerica_CFU_Votazione < 30){ FFVariabileNumerica_CFU_Votazione++;
}
Upvotes: 1