1.performSelector
[Self performselector: @selector (Delaymethod) withobject:nil/* can pass any type parameter * /Afterdelay: 2.0];
Note: This method is a non-blocking execution, and no method is found to cancel execution.
2.NSTimer Timer
Nstimer *timer = [Nstimer scheduledtimerwithtimeinterval:2.0 target:self selector: @selector (Delaymethod) Userinfo:nil Repeats:no];
Note: This method is a non-blocking execution mode,
Cancel execution method: - (void)invalidate; You can
3.NSThread Thread of Sleep
[Nsthread sleepfortimeinterval:2.0];
Note: This method is a blocking execution method that is recommended to be executed in a sub-thread, otherwise it will get stuck in the interface. However, sometimes it is necessary to block execution, such as entering the boot page (ad display) to sleep 2 seconds before entering the main interface.
The cancel execution method was not found.
4.GCD
__block Viewcontroller/* Host controller * /*weakself = = Dispatch_time (Dispatch_time_now, ( int64_t) (2.0 */* deferred execution time */*^{ [weakself Delaymethod];}); `
Note: This method can select the executing thread in the parameter, which is a non-blocking execution mode. The cancel execution method was not found.
Several common methods of delaying execution in iOS