iOS Development multithreaded Article-GCD common usage-top of the text

Source: Internet
Author: User

Original http://www.cnblogs.com/wendingding/p/3807716.html
 1//2//Yyviewcontroller.m3//Common use of 01-GCD (deferred execution)4//5//Created by Apple on 14-6-25.6//Copyright (c) 2014 itcase. All rights reserved.7//87 mImport"YYViewController.h "10@interface Yyviewcontroller ()12@end14@implementation Yyviewcontroller1617-(void) Viewdidload18 {19 [Super Viewdidload];NSLog (@"Print thread----%@ ", [Nsthread CurrentThread]);21st//Deferred execution22//First method: Delay of 3 seconds call the Run function[Self Performselector:@selector (Run) Withobject:nil Afterdelay:2.0];2425}26-(void) Run27 {NSLog (@"Deferred execution----%@ ", [Nsthread CurrentThread]);29}3031-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event32 {33 // execute 34 Dispatch_ in an async function queue_t queue = dispatch_queue_create ( "wendingding", 0); 35 36 Dispatch_sync (queue, ^{37 [self Performselector: @selector (test) Withobject:nil Afterdelay:1.0];< Span class= "number" >38}); 39 NSLog (@ " Async function"); 41-(void) test42 {43 NSLog (@ " Async function Deferred execution----%@", [Nsthread CurrentThread]); 45 @end             

Common uses for iOS development multithreaded-GCD-top of the text

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.