Reputation: 135
I have a problem. What i want to do is to click on button few times, and then update a label ONCE, but after 2 seconds delay, so if you click fast, nothing change, but when you stop, then the label updates.
Perform selector metods only create queue, so it will updates everytime button is pressed.
-(IBAction)clickButton {
i++;
[self updateLabel if clicking stop 3 seconds ago];
}
Upvotes: 0
Views: 253
Reputation: 62686
[NSObject cancelPreviousPerformRequestsWithTarget:self];
// then
[self performSelector ...];
Upvotes: 3