Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay/Time Objective-C Statement Execution

Tags:

objective-c

So I have this code moving an NSButton to the coordinates listed

[[MyNSButton animator] setFrame:NSMakeRect(567, 228, 109, 151)];

Then I have the same code moving another NSButton

[[MyNSButton2 animator] setFrame:NSMakeRect(695, 228, 109, 151)];

What I want to do is have the first statement execute, and then when the entire animation is over, and after a delay of maybe .5 seconds, have the next one go. How can I do that?

like image 220
Regan Avatar asked Aug 07 '26 00:08

Regan


1 Answers

You need to use NSTimer Here is the code how to do that

[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(getnextButton) userInfo:nil repeats:NO];

where getnextButton is the method that would be called after .5 seconds. put the code in this method which you want to execute after .5 seconds.

Hope this would help you.

like image 176
Sabby Avatar answered Aug 10 '26 07:08

Sabby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!