objective c - Set UIAlert to appear after x amount of IBAction presses -


is there simple way of setting piece of code check amount of presses before using uialertview,

for example,

if ibaction has been pressed 30 times, show uialertview, can alert, it's figuring how count 30 presses?

thanks both, have gotten little further, here code, using count int here;

it works, aim if user has purchased upgrade count ignored... @ moment, if user upgrades, still uialert on every 30 presses

- (ibaction)setrandomtext {      selectedrecnumber = (arc4random() % kmaxrecords);     nsstring *text = [alltext objectatindex:selectedrecnumber];    [randomtext settext:text];     count++;      if (![mkstoremanager featurebpurchased] ) {          if(count == 30)         {             count = 0;          uialertview *alert = [[uialertview alloc]initwithtitle:@"limit" message:@"reached limit!" delegate:self cancelbuttontitle:@"no" otherbuttontitles:@"ok",nil];         [alert show];         [alert release];       }else{      } }  } 

--- edit fixed using method;

   if (kmaxrecords == 35) {              if(count == 30)             {                 count = 0;  }else{  }  } 

you can count yourself.
create int variable , increment each time user presses button.
check if number bigger or equal 30 , if is, reset , show uialertview.

this pseudo code.

@interface yourclass : parentclass {    int numberofpresses = 0; } @end  @implementation yourclass -(ibaction)buttonpressed:(id)sender {    numberofpresses += 1;    if (numberofpresses >= 30) {       numberofpresses = 0;       uialertview *alert = [[uialertview alloc] initwithtitle:@"alert" message:@"your alert" delegate:nil cancelbuttontitle:@"cancel" otherbuttontitles:@"ok", nil];       [alert show];    } } @end 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -