How to delay action in IOS

Source: Internet
Author: User

1.

Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (2 * nsec_per_sec)), Dispatch_get_main_queue (), ^{

The code to execute

});

Nsec_per_sec represents the number of seconds, and it also provides the nsec_per_msec for milliseconds.

The true meaning of the above sentence is that after 2 seconds the task is added to the queue, not the execution after 2 seconds, most of the time the function can achieve our expectations, only in the case of very accurate timing requirements can be problematic.

2.

[Self Performselector: @selector (method to execute) withobject:nil Afterdelay:5];

GCD Detailed website:

http://blog.csdn.net/zhangao0086/article/details/38904923

How to delay action in IOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.