4. Common presentation methods and pros and cons in iOS

Source: Internet
Author: User

-(void) delay1{    //  deferred execution do not use sleep, bad: stuck to the current thread    [nsthread Sleepfortimeinterval:3];    NSLog (@ "-----Download Picture-----");}
-(void) delay2{    //  Once the delay task has been customized, the main current thread will not be jammed (which thread execution of the deferred task depends on where the current code is called)    [ Self performselector: @selector (Download:) Withobject:@ "http://555.jpg" afterdelay:  3];}
- (void) delay3{//3 seconds back to the main thread execute code in block//dispatch_queue_t queue = Dispatch_get_main_queue ();//Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (3 * nsec_per_sec)), queue, ^{//NSLog (@ "------task------%@", [Nsthread CurrentThread]);//    }); //automatically open a new thread after 3 seconds to execute the code in the block (that is, it will open a new thread for you to execute the code in the block after a period of time)dispatch_queue_t queue = Dispatch_get_global_queue (Dispatch_queue_priority_default,0); Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (3* nsec_per_sec)), queue, ^{NSLog (@"------Task------%@", [Nsthread CurrentThread]); });}

4. Common presentation methods and pros and cons 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.