Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kingthong

macrumors member
Original poster
Sep 20, 2010
62
0
Somewhere but not here.
Hi,

i have a method

-(IBAction) score: (id) sender{}

It is accessed by pressing down a button on the Iphone. i want it to run only 5 times. how do i achieve that?

Thanks.
 
I'd set up a counter and then only execute the code inside your method if the counter is <= 5. (Don't forget to increment the counter each time, as well.)
 
Create an integer instance variable in your controller to track the number of times it is called, increment in the action method and check the count as a guard clause?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.