How do I trigger a delay, let's say I want to call a method (once) in 3 seconds from now, and how do I cancel that call if I need to?
A flight delay is when an airline flight takes off and/or lands later than its scheduled time. The Federal Aviation Administration (FAA) considers a flight to be delayed when it is 15 minutes later than its scheduled time. A cancellation occurs when the airline does not operate the flight at all for a certain reason.
We regret to inform you that our ______________ (name of event) at _______________ (venue) on ________________ (date) has been ______________ (cancelled or postponed). We made this difficult decision to ___________ (postpone or cancel) because of _________________ (reason for cancellation or postponement).
Write an apology for the cancellation of event in your email“We are sorry to inform you”, “On behalf of committee/organization I apologize”, “Please accept our sincere apologies” and so on.
You can also use -[NSObject performSelector:awithObject:afterDelay:]
, and +[NSObject cancelPreviousPerformRequestsWithTarget:selector:object]
.
Use NSTimer. Use this to set up a call to method in three seconds time. It will only be called once:
[NSTimer scheduledTimerWithTimeInterval: 3
target: self
selector: @selector(method:)
userInfo: nil
repeats: NO];
method needs to look like this:
- (void) method: (NSTimer*) theTimer;
You can pass parameters into the method using userInfo (set to nil in the above example). It can be accessed in the method as [theTimer userInfo].
Use the invalidate method on NSTimer to cancel it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With