{"id":4307,"date":"2022-02-08T15:41:18","date_gmt":"2022-02-08T07:41:18","guid":{"rendered":"https:\/\/1989lifejourney.com\/?p=4307"},"modified":"2022-03-09T15:10:00","modified_gmt":"2022-03-09T07:10:00","slug":"ios-grand-central-dispatchgcd","status":"publish","type":"post","link":"https:\/\/1989lifejourney.com\/?p=4307","title":{"rendered":"IOS Grand Central Dispatch(GCD)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"dispatch-gcd\">Grand Central Dispatch(GCD):<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Dispatch, also known as Grand Central Dispatch (GCD), contains language features, runtime libraries, and system enhancements that provide systemic, comprehensive improvements to <strong>the support for concurrent code execution on multicore hardware in macOS, iOS, watchOS, and tvOS<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"dispatchqueue\">DispatchQueue:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An object that manages the execution of tasks serially or concurrently on your app&#8217;s main thread or on a background thread.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u4ee5\u4e0b\u662f\u95dc\u65bcDispatchQueue\u7684\u7a2e\u985e\u3001sync or async\u3001serial or concurrent\u3001Qos\u7684\u7a0b\u5f0f\u78bc<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(p.s. \u8a73\u7d30\u6982\u5ff5\u8aaa\u660e\u8acb\u53c3\u8003\u9019\u500b<a href=\"https:\/\/franksios.medium.com\/ios-gcd%E5%A4%9A%E5%9F%B7%E8%A1%8C%E7%B7%92%E7%9A%84%E8%AA%AA%E6%98%8E%E8%88%87%E6%87%89%E7%94%A8-c69a68d01da1\">\u9023\u7d50<\/a>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\/\/ Categories: main, global, custom\n<\/strong>DispatchQueue.main.async {\n    \n}\nDispatchQueue.global().async {\n    \n}\nDispatchQueue(label: \"Custom\").async {\n    \n}\n\n<strong>\/\/ Sync v.s. async\n<\/strong>DispatchQueue.global().sync {\n    \n}\nDispatchQueue.global().async {\n    \n}\n\n<strong>\/\/ Serial v.s. Concurrent\n<\/strong>DispatchQueue(label: \"serial\")\nDispatchQueue(label: \"concurrent\", attributes: .concurrent)\n\n<strong>\/\/Qos: Quality-of-service classes that specify the priorities for executing tasks.\n<\/strong>DispatchQueue(label: \"Custom1\", qos: .userInteractive)\nDispatchQueue(label: \"Custom2\", qos: .userInitiated)\nDispatchQueue(label: \"Custom3\", qos: .default)\nDispatchQueue(label: \"Custom4\", qos: .utility)\nDispatchQueue(label: \"Custom5\", qos: .background)\nDispatchQueue(label: \"Custom6\", qos: .unspecified)\n\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ref: <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/franksios.medium.com\/ios-gcd%E5%A4%9A%E5%9F%B7%E8%A1%8C%E7%B7%92%E7%9A%84%E8%AA%AA%E6%98%8E%E8%88%87%E6%87%89%E7%94%A8-c69a68d01da1\">https:\/\/franksios.medium.com\/ios-gcd%E5%A4%9A%E5%9F%B7%E8%A1%8C%E7%B7%92%E7%9A%84%E8%AA%AA%E6%98%8E%E8%88%87%E6%87%89%E7%94%A8-c69a68d01da1<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchqos\/qosclass\">https:\/\/developer.apple.com\/documentation\/dispatch\/dispatchqos\/qosclass<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.apple.com\/documentation\/DISPATCH\">https:\/\/developer.apple.com\/documentation\/DISPATCH<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grand Central Dispatch(GCD): Dispatch, also known as Gr [&hellip;]<\/p>\n","protected":false},"author":139426785,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_postgate_lock_override":"inherit","_postgate_lock_mode":"inherit","_postgate_preview_mode":"inherit","_postgate_preview_limit":0,"_postgate_product_ids":[],"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[37324612,1],"tags":[],"post_folder":[],"class_list":["post-4307","post","type-post","status-publish","format-standard","hentry","category-ios-development","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paR5vw-17t","jetpack-related-posts":[{"id":4774,"url":"https:\/\/1989lifejourney.com\/?p=4774","url_meta":{"origin":4307,"position":0},"title":"IOS DispatchGroup","author":"Kevin","date":"11 3 \u6708, 2022","format":false,"excerpt":"DispatchGroup A group of tasks that you monitor as\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5024,"url":"https:\/\/1989lifejourney.com\/?p=5024","url_meta":{"origin":4307,"position":1},"title":"IOS DispatchWorkItem","author":"Kevin","date":"31 3 \u6708, 2022","format":false,"excerpt":"Definition: The work you want to perform, encapsul\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4137,"url":"https:\/\/1989lifejourney.com\/?p=4137","url_meta":{"origin":4307,"position":2},"title":"Working in Thread Safe on iOS","author":"Kevin","date":"31 1 \u6708, 2022","format":false,"excerpt":"\u70ba\u4ec0\u9ebc\u8981\u4fdd\u8b49Thread Safe? Multiple threads \u540c\u6642\u9593\u5b58\u53d6data\uff0c\u6703\u5c0e\u81f4r\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=1050%2C600 3x, https:\/\/i0.wp.com\/1989lifejourney.com\/wp-content\/uploads\/2022\/01\/e688aae59c96-2022-01-31-e4b88be58d8810.21.20.png?resize=1400%2C800 4x"},"classes":[]},{"id":4037,"url":"https:\/\/1989lifejourney.com\/?p=4037","url_meta":{"origin":4307,"position":3},"title":"Bluetooth Communication(IOS Core Bluetooth)","author":"Kevin","date":"8 1 \u6708, 2022","format":false,"excerpt":"IOS Core Bluetooth\u662fbased on BLE(Bluetooth low ener\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4009,"url":"https:\/\/1989lifejourney.com\/?p=4009","url_meta":{"origin":4307,"position":4},"title":"Static vs Dynamic Dispatch in Swift","author":"Kevin","date":"6 1 \u6708, 2022","format":false,"excerpt":"\u4ee5\u4e0b\u5167\u5bb9\u53c3\u8003\u81ea[Ref]\uff0c\u9019\u88e1\u50c5\u4f5c\u500b\u4eba\u6458\u8981\u6574\u7406: Method Dispatch\u5b9a\u7fa9: Method\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5823,"url":"https:\/\/1989lifejourney.com\/?p=5823","url_meta":{"origin":4307,"position":5},"title":"IOS timer: the difference when timer schedule on main thread and background","author":"Kevin","date":"12 8 \u6708, 2022","format":false,"excerpt":"https:\/\/stackoverflow.com\/questions\/12323531\/diffe\u2026","rel":"","context":"\u5728\u300cIOS Development\u300d\u4e2d","block_context":{"text":"IOS Development","link":"https:\/\/1989lifejourney.com\/?cat=37324612"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/users\/139426785"}],"replies":[{"embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4307"}],"version-history":[{"count":8,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4307\/revisions"}],"predecessor-version":[{"id":4758,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=\/wp\/v2\/posts\/4307\/revisions\/4758"}],"wp:attachment":[{"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4307"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/1989lifejourney.com\/index.php?rest_route=%2Fwp%2Fv2%2Fpost_folder&post=4307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}