├── YSC-GCD-demo
├── YSC-GCD-demo.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── project.pbxproj
├── YSC-GCD-demo
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── AppDelegate.m
│ └── ViewController.m
├── YSC-GCD-demoTests
│ ├── Info.plist
│ └── YSC_GCD_demoTests.m
└── YSC-GCD-demoUITests
│ ├── Info.plist
│ └── YSC_GCD_demoUITests.m
├── .gitignore
└── LICENSE
/YSC-GCD-demo/YSC-GCD-demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // YSC-GCD-demo
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // YSC-GCD-demo
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // YSC-GCD-demo
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demoUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demoTests/YSC_GCD_demoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // YSC_GCD_demoTests.m
3 | // YSC-GCD-demoTests
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YSC_GCD_demoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation YSC_GCD_demoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demoUITests/YSC_GCD_demoUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // YSC_GCD_demoUITests.m
3 | // YSC-GCD-demoUITests
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YSC_GCD_demoUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation YSC_GCD_demoUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | # CocoaPods
32 | #
33 | # We recommend against adding the Pods directory to your .gitignore. However
34 | # you should judge for yourself, the pros and cons are mentioned at:
35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36 | #
37 | # Pods/
38 |
39 | # Carthage
40 | #
41 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
42 | # Carthage/Checkouts
43 |
44 | Carthage/Build
45 |
46 | # fastlane
47 | #
48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
49 | # screenshots whenever they are needed.
50 | # For more information about the recommended setup visit:
51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
52 |
53 | fastlane/report.xml
54 | fastlane/Preview.html
55 | fastlane/screenshots
56 | fastlane/test_output
57 |
58 | # Code Injection
59 | #
60 | # After new code Injection tools there's a generated folder /iOSInjectionProject
61 | # https://github.com/johnno1962/injectionforxcode
62 |
63 | iOSInjectionProject/
64 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | }
88 | ],
89 | "info" : {
90 | "version" : 1,
91 | "author" : "xcode"
92 | }
93 | }
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // YSC-GCD-demo
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // YSC-GCD-demo
4 | //
5 | // Created by Walking Boy on 2018/2/13.
6 | // Copyright © 2018年 Walking Boy. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | /* 剩余火车票数 */
14 | @property (nonatomic, assign) int ticketSurplusCount;
15 |
16 | @end
17 |
18 | @implementation ViewController
19 | {
20 | dispatch_semaphore_t semaphoreLock;
21 | }
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 |
26 | /* 任务+队列 相关方法 */
27 |
28 | // 同步执行 + 并发队列
29 | // [self syncConcurrent];
30 |
31 | // 异步执行 + 并发队列
32 | // [self asyncConcurrent];
33 |
34 | // 同步执行 + 串行队列
35 | // [self syncSerial];
36 |
37 | // 异步执行 + 串行队列
38 | // [self asyncSerial];
39 |
40 | // 同步执行 + 主队列(主线程调用)
41 | // [self syncMain];
42 |
43 | // 同步执行 + 主队列(其他线程调用)
44 | // [NSThread detachNewThreadSelector:@selector(syncMain) toTarget:self withObject:nil];
45 |
46 | // 异步执行 + 主队列
47 | // [self asyncMain];
48 |
49 | /* GCD 线程间通信 */
50 |
51 | // [self communication];
52 |
53 |
54 | /* GCD 其他方法 */
55 |
56 | // 栅栏方法 dispatch_barrier_async
57 | // [self barrier];
58 |
59 | // 延时执行方法 dispatch_after
60 | // [self after];
61 |
62 | // 一次性代码(只执行一次)dispatch_once
63 | // [self once];
64 |
65 | // 快速迭代方法 dispatch_apply
66 | // [self apply];
67 |
68 | /* 队列组 gropu */
69 | // 队列组 dispatch_group_notify
70 | // [self groupNotify];
71 |
72 | // 队列组 dispatch_group_wait
73 | // [self groupWait];
74 |
75 | // 队列组 dispatch_group_enter、dispatch_group_leave
76 | // [self groupEnterAndLeave];
77 |
78 | /* 信号量 dispatch_semaphore */
79 | // semaphore 线程同步
80 | // [self semaphoreSync];
81 |
82 | // semaphore 线程安全
83 | // 非线程安全:不使用 semaphore
84 | // [self initTicketStatusNotSave];
85 |
86 | // 线程安全:使用 semaphore 加锁
87 | // [self initTicketStatusSave];
88 | }
89 |
90 |
91 | #pragma mark - 任务+队列 相关方法
92 |
93 | /**
94 | * 同步执行 + 并发队列
95 | * 特点:在当前线程中执行任务,不会开启新线程,执行完一个任务,再执行下一个任务。
96 | */
97 | - (void)syncConcurrent {
98 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
99 | NSLog(@"syncConcurrent---begin");
100 |
101 | dispatch_queue_t queue = dispatch_queue_create("net.bujige.testQueue", DISPATCH_QUEUE_CONCURRENT);
102 |
103 | dispatch_sync(queue, ^{
104 | // 追加任务 1
105 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
106 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
107 | });
108 |
109 | dispatch_sync(queue, ^{
110 | // 追加任务 2
111 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
112 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
113 | });
114 |
115 | dispatch_sync(queue, ^{
116 | // 追加任务 3
117 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
118 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
119 | });
120 |
121 | NSLog(@"syncConcurrent---end");
122 | }
123 |
124 | /**
125 | * 异步执行 + 并发队列
126 | * 特点:可以开启多个线程,任务交替(同时)执行。
127 | */
128 | - (void)asyncConcurrent {
129 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
130 | NSLog(@"asyncConcurrent---begin");
131 |
132 | dispatch_queue_t queue = dispatch_queue_create("net.bujige.testQueue", DISPATCH_QUEUE_CONCURRENT);
133 |
134 | dispatch_async(queue, ^{
135 | // 追加任务 1
136 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
137 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
138 | });
139 |
140 | dispatch_async(queue, ^{
141 | // 追加任务 2
142 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
143 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
144 | });
145 |
146 | dispatch_async(queue, ^{
147 | // 追加任务 3
148 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
149 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
150 | });
151 |
152 | NSLog(@"asyncConcurrent---end");
153 | }
154 |
155 | /**
156 | * 同步执行 + 串行队列
157 | * 特点:不会开启新线程,在当前线程执行任务。任务是串行的,执行完一个任务,再执行下一个任务。
158 | */
159 | - (void)syncSerial {
160 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
161 | NSLog(@"syncSerial---begin");
162 |
163 | dispatch_queue_t queue = dispatch_queue_create("net.bujige.testQueue", DISPATCH_QUEUE_SERIAL);
164 |
165 | dispatch_sync(queue, ^{
166 | // 追加任务 1
167 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
168 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
169 | });
170 | dispatch_sync(queue, ^{
171 | // 追加任务 2
172 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
173 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
174 | });
175 | dispatch_sync(queue, ^{
176 | // 追加任务 3
177 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
178 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
179 | });
180 |
181 | NSLog(@"syncSerial---end");
182 | }
183 |
184 | /**
185 | * 异步执行 + 串行队列
186 | * 特点:会开启新线程,但是因为任务是串行的,执行完一个任务,再执行下一个任务。
187 | */
188 | - (void)asyncSerial {
189 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
190 | NSLog(@"asyncSerial---begin");
191 |
192 | dispatch_queue_t queue = dispatch_queue_create("net.bujige.testQueue", DISPATCH_QUEUE_SERIAL);
193 |
194 | dispatch_async(queue, ^{
195 | // 追加任务 1
196 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
197 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
198 | });
199 | dispatch_async(queue, ^{
200 | // 追加任务 2
201 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
202 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
203 | });
204 | dispatch_async(queue, ^{
205 | // 追加任务 3
206 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
207 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
208 | });
209 |
210 | NSLog(@"asyncSerial---end");
211 | }
212 |
213 | /**
214 | * 同步执行 + 主队列
215 | * 特点(主线程调用):互等卡主不执行。
216 | * 特点(其他线程调用):不会开启新线程,执行完一个任务,再执行下一个任务。
217 | */
218 | - (void)syncMain {
219 |
220 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
221 | NSLog(@"syncMain---begin");
222 |
223 | dispatch_queue_t queue = dispatch_get_main_queue();
224 |
225 | dispatch_sync(queue, ^{
226 | // 追加任务 1
227 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
228 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
229 | });
230 |
231 | dispatch_sync(queue, ^{
232 | // 追加任务 2
233 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
234 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
235 | });
236 |
237 | dispatch_sync(queue, ^{
238 | // 追加任务 3
239 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
240 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
241 | });
242 |
243 | NSLog(@"syncMain---end");
244 | }
245 |
246 | /**
247 | * 异步执行 + 主队列
248 | * 特点:只在主线程中执行任务,执行完一个任务,再执行下一个任务
249 | */
250 | - (void)asyncMain {
251 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
252 | NSLog(@"asyncMain---begin");
253 |
254 | dispatch_queue_t queue = dispatch_get_main_queue();
255 |
256 | dispatch_async(queue, ^{
257 | // 追加任务 1
258 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
259 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
260 | });
261 |
262 | dispatch_async(queue, ^{
263 | // 追加任务 2
264 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
265 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
266 | });
267 |
268 | dispatch_async(queue, ^{
269 | // 追加任务 3
270 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
271 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
272 | });
273 |
274 | NSLog(@"asyncMain---end");
275 | }
276 |
277 |
278 | #pragma mark - 线程间通信
279 |
280 | /**
281 | * 线程间通信
282 | */
283 | - (void)communication {
284 | // 获取全局并发队列
285 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
286 | // 获取主队列
287 | dispatch_queue_t mainQueue = dispatch_get_main_queue();
288 |
289 | dispatch_async(queue, ^{
290 | // 异步追加任务 1
291 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
292 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
293 |
294 | // 回到主线程
295 | dispatch_async(mainQueue, ^{
296 | // 追加在主线程中执行的任务
297 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
298 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
299 | });
300 | });
301 | }
302 |
303 |
304 | #pragma mark - GCD 其他相关方法
305 |
306 | /**
307 | * 栅栏方法 dispatch_barrier_async
308 | */
309 | - (void)barrier {
310 | dispatch_queue_t queue = dispatch_queue_create("net.bujige.testQueue", DISPATCH_QUEUE_CONCURRENT);
311 |
312 | dispatch_async(queue, ^{
313 | // 追加任务 1
314 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
315 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
316 | });
317 | dispatch_async(queue, ^{
318 | // 追加任务 2
319 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
320 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
321 | });
322 |
323 | dispatch_barrier_async(queue, ^{
324 | // 追加任务 barrier
325 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
326 | NSLog(@"barrier---%@",[NSThread currentThread]);// 打印当前线程
327 | });
328 |
329 | dispatch_async(queue, ^{
330 | // 追加任务 3
331 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
332 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
333 | });
334 | dispatch_async(queue, ^{
335 | // 追加任务 4
336 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
337 | NSLog(@"4---%@",[NSThread currentThread]); // 打印当前线程
338 | });
339 | }
340 |
341 | /**
342 | * 延时执行方法 dispatch_after
343 | */
344 | - (void)after {
345 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
346 | NSLog(@"asyncMain---begin");
347 |
348 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
349 | // 2.0 秒后异步追加任务代码到主队列,并开始执行
350 | NSLog(@"after---%@",[NSThread currentThread]); // 打印当前线程
351 | });
352 | }
353 |
354 | /**
355 | * 一次性代码(只执行一次)dispatch_once
356 | */
357 | - (void)once {
358 | static dispatch_once_t onceToken;
359 | dispatch_once(&onceToken, ^{
360 | // 只执行 1 次的代码(这里面默认是线程安全的)
361 | });
362 | }
363 |
364 | /**
365 | * 快速迭代方法 dispatch_apply
366 | */
367 | - (void)apply {
368 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
369 |
370 | NSLog(@"apply---begin");
371 | dispatch_apply(6, queue, ^(size_t index) {
372 | NSLog(@"%zd---%@",index, [NSThread currentThread]);
373 | });
374 | NSLog(@"apply---end");
375 | }
376 |
377 | #pragma mark - dispatch_group 队列组
378 |
379 | /**
380 | * 队列组 dispatch_group_notify
381 | */
382 | - (void)groupNotify {
383 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
384 | NSLog(@"group---begin");
385 |
386 | dispatch_group_t group = dispatch_group_create();
387 |
388 | dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
389 | // 追加任务 1
390 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
391 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
392 | });
393 |
394 | dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
395 | // 追加任务 2
396 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
397 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
398 | });
399 |
400 | dispatch_group_notify(group, dispatch_get_main_queue(), ^{
401 | // 等前面的异步任务 1、任务 2 都执行完毕后,回到主线程执行下边任务
402 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
403 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
404 |
405 | NSLog(@"group---end");
406 | });
407 | }
408 |
409 | /**
410 | * 队列组 dispatch_group_wait
411 | */
412 | - (void)groupWait {
413 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
414 | NSLog(@"group---begin");
415 |
416 | dispatch_group_t group = dispatch_group_create();
417 |
418 | dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
419 | // 追加任务 1
420 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
421 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
422 | });
423 |
424 | dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
425 | // 追加任务 2
426 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
427 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
428 | });
429 |
430 | // 等待上面的任务全部完成后,会往下继续执行(会阻塞当前线程)
431 | dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
432 |
433 | NSLog(@"group---end");
434 |
435 | }
436 |
437 | /**
438 | * 队列组 dispatch_group_enter、dispatch_group_leave
439 | */
440 | - (void)groupEnterAndLeave {
441 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
442 | NSLog(@"group---begin");
443 |
444 | dispatch_group_t group = dispatch_group_create();
445 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
446 | dispatch_group_enter(group);
447 | dispatch_async(queue, ^{
448 | // 追加任务 1
449 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
450 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
451 |
452 | dispatch_group_leave(group);
453 | });
454 |
455 | dispatch_group_enter(group);
456 | dispatch_async(queue, ^{
457 | // 追加任务 2
458 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
459 | NSLog(@"2---%@",[NSThread currentThread]); // 打印当前线程
460 |
461 | dispatch_group_leave(group);
462 | });
463 |
464 | dispatch_group_notify(group, dispatch_get_main_queue(), ^{
465 | // 等前面的异步操作都执行完毕后,回到主线程.
466 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
467 | NSLog(@"3---%@",[NSThread currentThread]); // 打印当前线程
468 |
469 | NSLog(@"group---end");
470 | });
471 | }
472 |
473 | #pragma mark - semaphore 线程同步
474 |
475 | /**
476 | * semaphore 线程同步
477 | */
478 | - (void)semaphoreSync {
479 |
480 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
481 | NSLog(@"semaphore---begin");
482 |
483 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
484 | dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
485 |
486 | __block int number = 0;
487 | dispatch_async(queue, ^{
488 | // 追加任务 1
489 | [NSThread sleepForTimeInterval:2]; // 模拟耗时操作
490 | NSLog(@"1---%@",[NSThread currentThread]); // 打印当前线程
491 |
492 | number = 100;
493 |
494 | dispatch_semaphore_signal(semaphore);
495 | });
496 |
497 | dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
498 | NSLog(@"semaphore---end,number = %zd",number);
499 | }
500 |
501 | #pragma mark - semaphore 线程安全
502 | /**
503 | * 非线程安全:不使用 semaphore
504 | * 初始化火车票数量、卖票窗口(非线程安全)、并开始卖票
505 | */
506 | - (void)initTicketStatusNotSave {
507 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
508 | NSLog(@"semaphore---begin");
509 |
510 | self.ticketSurplusCount = 50;
511 |
512 | // queue1 代表北京火车票售卖窗口
513 | dispatch_queue_t queue1 = dispatch_queue_create("net.bujige.testQueue1", DISPATCH_QUEUE_SERIAL);
514 | // queue2 代表上海火车票售卖窗口
515 | dispatch_queue_t queue2 = dispatch_queue_create("net.bujige.testQueue2", DISPATCH_QUEUE_SERIAL);
516 |
517 | __weak typeof(self) weakSelf = self;
518 | dispatch_async(queue1, ^{
519 | [weakSelf saleTicketNotSafe];
520 | });
521 |
522 | dispatch_async(queue2, ^{
523 | [weakSelf saleTicketNotSafe];
524 | });
525 | }
526 |
527 | /**
528 | * 售卖火车票(非线程安全)
529 | */
530 | - (void)saleTicketNotSafe {
531 | while (1) {
532 |
533 | if (self.ticketSurplusCount > 0) { //如果还有票,继续售卖
534 | self.ticketSurplusCount--;
535 | NSLog(@"%@", [NSString stringWithFormat:@"剩余票数:%d 窗口:%@", self.ticketSurplusCount, [NSThread currentThread]]);
536 | [NSThread sleepForTimeInterval:0.2];
537 | } else { // 如果已卖完,关闭售票窗口
538 | NSLog(@"所有火车票均已售完");
539 | break;
540 | }
541 |
542 | }
543 | }
544 |
545 | /**
546 | * 线程安全:使用 semaphore 加锁
547 | * 初始化火车票数量、卖票窗口(线程安全)、并开始卖票
548 | */
549 | - (void)initTicketStatusSave {
550 | NSLog(@"currentThread---%@",[NSThread currentThread]); // 打印当前线程
551 | NSLog(@"semaphore---begin");
552 |
553 | semaphoreLock = dispatch_semaphore_create(1);
554 |
555 | self.ticketSurplusCount = 50;
556 |
557 | // queue1 代表北京火车票售卖窗口
558 | dispatch_queue_t queue1 = dispatch_queue_create("net.bujige.testQueue1", DISPATCH_QUEUE_SERIAL);
559 | // queue2 代表上海火车票售卖窗口
560 | dispatch_queue_t queue2 = dispatch_queue_create("net.bujige.testQueue2", DISPATCH_QUEUE_SERIAL);
561 |
562 | __weak typeof(self) weakSelf = self;
563 | dispatch_async(queue1, ^{
564 | [weakSelf saleTicketSafe];
565 | });
566 |
567 | dispatch_async(queue2, ^{
568 | [weakSelf saleTicketSafe];
569 | });
570 | }
571 |
572 | /**
573 | * 售卖火车票(线程安全)
574 | */
575 | - (void)saleTicketSafe {
576 | while (1) {
577 | // 相当于加锁
578 | dispatch_semaphore_wait(semaphoreLock, DISPATCH_TIME_FOREVER);
579 |
580 | if (self.ticketSurplusCount > 0) { // 如果还有票,继续售卖
581 | self.ticketSurplusCount--;
582 | NSLog(@"%@", [NSString stringWithFormat:@"剩余票数:%d 窗口:%@", self.ticketSurplusCount, [NSThread currentThread]]);
583 | [NSThread sleepForTimeInterval:0.2];
584 | } else { // 如果已卖完,关闭售票窗口
585 | NSLog(@"所有火车票均已售完");
586 |
587 | // 相当于解锁
588 | dispatch_semaphore_signal(semaphoreLock);
589 | break;
590 | }
591 |
592 | // 相当于解锁
593 | dispatch_semaphore_signal(semaphoreLock);
594 | }
595 | }
596 |
597 | @end
598 |
--------------------------------------------------------------------------------
/YSC-GCD-demo/YSC-GCD-demo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 935724962032FFBC00850BC9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 935724952032FFBC00850BC9 /* AppDelegate.m */; };
11 | 935724992032FFBC00850BC9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 935724982032FFBC00850BC9 /* ViewController.m */; };
12 | 9357249C2032FFBC00850BC9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9357249A2032FFBC00850BC9 /* Main.storyboard */; };
13 | 9357249E2032FFBC00850BC9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9357249D2032FFBC00850BC9 /* Assets.xcassets */; };
14 | 935724A12032FFBC00850BC9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9357249F2032FFBC00850BC9 /* LaunchScreen.storyboard */; };
15 | 935724A42032FFBC00850BC9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 935724A32032FFBC00850BC9 /* main.m */; };
16 | 935724AE2032FFBC00850BC9 /* YSC_GCD_demoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 935724AD2032FFBC00850BC9 /* YSC_GCD_demoTests.m */; };
17 | 935724B92032FFBC00850BC9 /* YSC_GCD_demoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 935724B82032FFBC00850BC9 /* YSC_GCD_demoUITests.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXContainerItemProxy section */
21 | 935724AA2032FFBC00850BC9 /* PBXContainerItemProxy */ = {
22 | isa = PBXContainerItemProxy;
23 | containerPortal = 935724892032FFBB00850BC9 /* Project object */;
24 | proxyType = 1;
25 | remoteGlobalIDString = 935724902032FFBB00850BC9;
26 | remoteInfo = "YSC-GCD-demo";
27 | };
28 | 935724B52032FFBC00850BC9 /* PBXContainerItemProxy */ = {
29 | isa = PBXContainerItemProxy;
30 | containerPortal = 935724892032FFBB00850BC9 /* Project object */;
31 | proxyType = 1;
32 | remoteGlobalIDString = 935724902032FFBB00850BC9;
33 | remoteInfo = "YSC-GCD-demo";
34 | };
35 | /* End PBXContainerItemProxy section */
36 |
37 | /* Begin PBXFileReference section */
38 | 935724912032FFBB00850BC9 /* YSC-GCD-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "YSC-GCD-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
39 | 935724942032FFBB00850BC9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
40 | 935724952032FFBC00850BC9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
41 | 935724972032FFBC00850BC9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
42 | 935724982032FFBC00850BC9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
43 | 9357249B2032FFBC00850BC9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
44 | 9357249D2032FFBC00850BC9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
45 | 935724A02032FFBC00850BC9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
46 | 935724A22032FFBC00850BC9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
47 | 935724A32032FFBC00850BC9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
48 | 935724A92032FFBC00850BC9 /* YSC-GCD-demoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "YSC-GCD-demoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 935724AD2032FFBC00850BC9 /* YSC_GCD_demoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YSC_GCD_demoTests.m; sourceTree = ""; };
50 | 935724AF2032FFBC00850BC9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
51 | 935724B42032FFBC00850BC9 /* YSC-GCD-demoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "YSC-GCD-demoUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 935724B82032FFBC00850BC9 /* YSC_GCD_demoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YSC_GCD_demoUITests.m; sourceTree = ""; };
53 | 935724BA2032FFBC00850BC9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
54 | /* End PBXFileReference section */
55 |
56 | /* Begin PBXFrameworksBuildPhase section */
57 | 9357248E2032FFBB00850BC9 /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | 935724A62032FFBC00850BC9 /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | 935724B12032FFBC00850BC9 /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | );
76 | runOnlyForDeploymentPostprocessing = 0;
77 | };
78 | /* End PBXFrameworksBuildPhase section */
79 |
80 | /* Begin PBXGroup section */
81 | 935724882032FFBB00850BC9 = {
82 | isa = PBXGroup;
83 | children = (
84 | 935724932032FFBB00850BC9 /* YSC-GCD-demo */,
85 | 935724AC2032FFBC00850BC9 /* YSC-GCD-demoTests */,
86 | 935724B72032FFBC00850BC9 /* YSC-GCD-demoUITests */,
87 | 935724922032FFBB00850BC9 /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | 935724922032FFBB00850BC9 /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | 935724912032FFBB00850BC9 /* YSC-GCD-demo.app */,
95 | 935724A92032FFBC00850BC9 /* YSC-GCD-demoTests.xctest */,
96 | 935724B42032FFBC00850BC9 /* YSC-GCD-demoUITests.xctest */,
97 | );
98 | name = Products;
99 | sourceTree = "";
100 | };
101 | 935724932032FFBB00850BC9 /* YSC-GCD-demo */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 935724942032FFBB00850BC9 /* AppDelegate.h */,
105 | 935724952032FFBC00850BC9 /* AppDelegate.m */,
106 | 935724972032FFBC00850BC9 /* ViewController.h */,
107 | 935724982032FFBC00850BC9 /* ViewController.m */,
108 | 9357249A2032FFBC00850BC9 /* Main.storyboard */,
109 | 9357249D2032FFBC00850BC9 /* Assets.xcassets */,
110 | 9357249F2032FFBC00850BC9 /* LaunchScreen.storyboard */,
111 | 935724A22032FFBC00850BC9 /* Info.plist */,
112 | 935724A32032FFBC00850BC9 /* main.m */,
113 | );
114 | path = "YSC-GCD-demo";
115 | sourceTree = "";
116 | };
117 | 935724AC2032FFBC00850BC9 /* YSC-GCD-demoTests */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 935724AD2032FFBC00850BC9 /* YSC_GCD_demoTests.m */,
121 | 935724AF2032FFBC00850BC9 /* Info.plist */,
122 | );
123 | path = "YSC-GCD-demoTests";
124 | sourceTree = "";
125 | };
126 | 935724B72032FFBC00850BC9 /* YSC-GCD-demoUITests */ = {
127 | isa = PBXGroup;
128 | children = (
129 | 935724B82032FFBC00850BC9 /* YSC_GCD_demoUITests.m */,
130 | 935724BA2032FFBC00850BC9 /* Info.plist */,
131 | );
132 | path = "YSC-GCD-demoUITests";
133 | sourceTree = "";
134 | };
135 | /* End PBXGroup section */
136 |
137 | /* Begin PBXNativeTarget section */
138 | 935724902032FFBB00850BC9 /* YSC-GCD-demo */ = {
139 | isa = PBXNativeTarget;
140 | buildConfigurationList = 935724BD2032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demo" */;
141 | buildPhases = (
142 | 9357248D2032FFBB00850BC9 /* Sources */,
143 | 9357248E2032FFBB00850BC9 /* Frameworks */,
144 | 9357248F2032FFBB00850BC9 /* Resources */,
145 | );
146 | buildRules = (
147 | );
148 | dependencies = (
149 | );
150 | name = "YSC-GCD-demo";
151 | productName = "YSC-GCD-demo";
152 | productReference = 935724912032FFBB00850BC9 /* YSC-GCD-demo.app */;
153 | productType = "com.apple.product-type.application";
154 | };
155 | 935724A82032FFBC00850BC9 /* YSC-GCD-demoTests */ = {
156 | isa = PBXNativeTarget;
157 | buildConfigurationList = 935724C02032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demoTests" */;
158 | buildPhases = (
159 | 935724A52032FFBC00850BC9 /* Sources */,
160 | 935724A62032FFBC00850BC9 /* Frameworks */,
161 | 935724A72032FFBC00850BC9 /* Resources */,
162 | );
163 | buildRules = (
164 | );
165 | dependencies = (
166 | 935724AB2032FFBC00850BC9 /* PBXTargetDependency */,
167 | );
168 | name = "YSC-GCD-demoTests";
169 | productName = "YSC-GCD-demoTests";
170 | productReference = 935724A92032FFBC00850BC9 /* YSC-GCD-demoTests.xctest */;
171 | productType = "com.apple.product-type.bundle.unit-test";
172 | };
173 | 935724B32032FFBC00850BC9 /* YSC-GCD-demoUITests */ = {
174 | isa = PBXNativeTarget;
175 | buildConfigurationList = 935724C32032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demoUITests" */;
176 | buildPhases = (
177 | 935724B02032FFBC00850BC9 /* Sources */,
178 | 935724B12032FFBC00850BC9 /* Frameworks */,
179 | 935724B22032FFBC00850BC9 /* Resources */,
180 | );
181 | buildRules = (
182 | );
183 | dependencies = (
184 | 935724B62032FFBC00850BC9 /* PBXTargetDependency */,
185 | );
186 | name = "YSC-GCD-demoUITests";
187 | productName = "YSC-GCD-demoUITests";
188 | productReference = 935724B42032FFBC00850BC9 /* YSC-GCD-demoUITests.xctest */;
189 | productType = "com.apple.product-type.bundle.ui-testing";
190 | };
191 | /* End PBXNativeTarget section */
192 |
193 | /* Begin PBXProject section */
194 | 935724892032FFBB00850BC9 /* Project object */ = {
195 | isa = PBXProject;
196 | attributes = {
197 | LastUpgradeCheck = 0900;
198 | ORGANIZATIONNAME = "Walking Boy";
199 | TargetAttributes = {
200 | 935724902032FFBB00850BC9 = {
201 | CreatedOnToolsVersion = 9.0;
202 | ProvisioningStyle = Automatic;
203 | };
204 | 935724A82032FFBC00850BC9 = {
205 | CreatedOnToolsVersion = 9.0;
206 | ProvisioningStyle = Automatic;
207 | TestTargetID = 935724902032FFBB00850BC9;
208 | };
209 | 935724B32032FFBC00850BC9 = {
210 | CreatedOnToolsVersion = 9.0;
211 | ProvisioningStyle = Automatic;
212 | TestTargetID = 935724902032FFBB00850BC9;
213 | };
214 | };
215 | };
216 | buildConfigurationList = 9357248C2032FFBB00850BC9 /* Build configuration list for PBXProject "YSC-GCD-demo" */;
217 | compatibilityVersion = "Xcode 8.0";
218 | developmentRegion = en;
219 | hasScannedForEncodings = 0;
220 | knownRegions = (
221 | en,
222 | Base,
223 | );
224 | mainGroup = 935724882032FFBB00850BC9;
225 | productRefGroup = 935724922032FFBB00850BC9 /* Products */;
226 | projectDirPath = "";
227 | projectRoot = "";
228 | targets = (
229 | 935724902032FFBB00850BC9 /* YSC-GCD-demo */,
230 | 935724A82032FFBC00850BC9 /* YSC-GCD-demoTests */,
231 | 935724B32032FFBC00850BC9 /* YSC-GCD-demoUITests */,
232 | );
233 | };
234 | /* End PBXProject section */
235 |
236 | /* Begin PBXResourcesBuildPhase section */
237 | 9357248F2032FFBB00850BC9 /* Resources */ = {
238 | isa = PBXResourcesBuildPhase;
239 | buildActionMask = 2147483647;
240 | files = (
241 | 935724A12032FFBC00850BC9 /* LaunchScreen.storyboard in Resources */,
242 | 9357249E2032FFBC00850BC9 /* Assets.xcassets in Resources */,
243 | 9357249C2032FFBC00850BC9 /* Main.storyboard in Resources */,
244 | );
245 | runOnlyForDeploymentPostprocessing = 0;
246 | };
247 | 935724A72032FFBC00850BC9 /* Resources */ = {
248 | isa = PBXResourcesBuildPhase;
249 | buildActionMask = 2147483647;
250 | files = (
251 | );
252 | runOnlyForDeploymentPostprocessing = 0;
253 | };
254 | 935724B22032FFBC00850BC9 /* Resources */ = {
255 | isa = PBXResourcesBuildPhase;
256 | buildActionMask = 2147483647;
257 | files = (
258 | );
259 | runOnlyForDeploymentPostprocessing = 0;
260 | };
261 | /* End PBXResourcesBuildPhase section */
262 |
263 | /* Begin PBXSourcesBuildPhase section */
264 | 9357248D2032FFBB00850BC9 /* Sources */ = {
265 | isa = PBXSourcesBuildPhase;
266 | buildActionMask = 2147483647;
267 | files = (
268 | 935724992032FFBC00850BC9 /* ViewController.m in Sources */,
269 | 935724A42032FFBC00850BC9 /* main.m in Sources */,
270 | 935724962032FFBC00850BC9 /* AppDelegate.m in Sources */,
271 | );
272 | runOnlyForDeploymentPostprocessing = 0;
273 | };
274 | 935724A52032FFBC00850BC9 /* Sources */ = {
275 | isa = PBXSourcesBuildPhase;
276 | buildActionMask = 2147483647;
277 | files = (
278 | 935724AE2032FFBC00850BC9 /* YSC_GCD_demoTests.m in Sources */,
279 | );
280 | runOnlyForDeploymentPostprocessing = 0;
281 | };
282 | 935724B02032FFBC00850BC9 /* Sources */ = {
283 | isa = PBXSourcesBuildPhase;
284 | buildActionMask = 2147483647;
285 | files = (
286 | 935724B92032FFBC00850BC9 /* YSC_GCD_demoUITests.m in Sources */,
287 | );
288 | runOnlyForDeploymentPostprocessing = 0;
289 | };
290 | /* End PBXSourcesBuildPhase section */
291 |
292 | /* Begin PBXTargetDependency section */
293 | 935724AB2032FFBC00850BC9 /* PBXTargetDependency */ = {
294 | isa = PBXTargetDependency;
295 | target = 935724902032FFBB00850BC9 /* YSC-GCD-demo */;
296 | targetProxy = 935724AA2032FFBC00850BC9 /* PBXContainerItemProxy */;
297 | };
298 | 935724B62032FFBC00850BC9 /* PBXTargetDependency */ = {
299 | isa = PBXTargetDependency;
300 | target = 935724902032FFBB00850BC9 /* YSC-GCD-demo */;
301 | targetProxy = 935724B52032FFBC00850BC9 /* PBXContainerItemProxy */;
302 | };
303 | /* End PBXTargetDependency section */
304 |
305 | /* Begin PBXVariantGroup section */
306 | 9357249A2032FFBC00850BC9 /* Main.storyboard */ = {
307 | isa = PBXVariantGroup;
308 | children = (
309 | 9357249B2032FFBC00850BC9 /* Base */,
310 | );
311 | name = Main.storyboard;
312 | sourceTree = "";
313 | };
314 | 9357249F2032FFBC00850BC9 /* LaunchScreen.storyboard */ = {
315 | isa = PBXVariantGroup;
316 | children = (
317 | 935724A02032FFBC00850BC9 /* Base */,
318 | );
319 | name = LaunchScreen.storyboard;
320 | sourceTree = "";
321 | };
322 | /* End PBXVariantGroup section */
323 |
324 | /* Begin XCBuildConfiguration section */
325 | 935724BB2032FFBC00850BC9 /* Debug */ = {
326 | isa = XCBuildConfiguration;
327 | buildSettings = {
328 | ALWAYS_SEARCH_USER_PATHS = NO;
329 | CLANG_ANALYZER_NONNULL = YES;
330 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
331 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
332 | CLANG_CXX_LIBRARY = "libc++";
333 | CLANG_ENABLE_MODULES = YES;
334 | CLANG_ENABLE_OBJC_ARC = YES;
335 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
336 | CLANG_WARN_BOOL_CONVERSION = YES;
337 | CLANG_WARN_COMMA = YES;
338 | CLANG_WARN_CONSTANT_CONVERSION = YES;
339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
340 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INFINITE_RECURSION = YES;
344 | CLANG_WARN_INT_CONVERSION = YES;
345 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
346 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
348 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
349 | CLANG_WARN_STRICT_PROTOTYPES = YES;
350 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
351 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
352 | CLANG_WARN_UNREACHABLE_CODE = YES;
353 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
354 | CODE_SIGN_IDENTITY = "iPhone Developer";
355 | COPY_PHASE_STRIP = NO;
356 | DEBUG_INFORMATION_FORMAT = dwarf;
357 | ENABLE_STRICT_OBJC_MSGSEND = YES;
358 | ENABLE_TESTABILITY = YES;
359 | GCC_C_LANGUAGE_STANDARD = gnu11;
360 | GCC_DYNAMIC_NO_PIC = NO;
361 | GCC_NO_COMMON_BLOCKS = YES;
362 | GCC_OPTIMIZATION_LEVEL = 0;
363 | GCC_PREPROCESSOR_DEFINITIONS = (
364 | "DEBUG=1",
365 | "$(inherited)",
366 | );
367 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
368 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
369 | GCC_WARN_UNDECLARED_SELECTOR = YES;
370 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
371 | GCC_WARN_UNUSED_FUNCTION = YES;
372 | GCC_WARN_UNUSED_VARIABLE = YES;
373 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
374 | MTL_ENABLE_DEBUG_INFO = YES;
375 | ONLY_ACTIVE_ARCH = YES;
376 | SDKROOT = iphoneos;
377 | };
378 | name = Debug;
379 | };
380 | 935724BC2032FFBC00850BC9 /* Release */ = {
381 | isa = XCBuildConfiguration;
382 | buildSettings = {
383 | ALWAYS_SEARCH_USER_PATHS = NO;
384 | CLANG_ANALYZER_NONNULL = YES;
385 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
386 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
387 | CLANG_CXX_LIBRARY = "libc++";
388 | CLANG_ENABLE_MODULES = YES;
389 | CLANG_ENABLE_OBJC_ARC = YES;
390 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
391 | CLANG_WARN_BOOL_CONVERSION = YES;
392 | CLANG_WARN_COMMA = YES;
393 | CLANG_WARN_CONSTANT_CONVERSION = YES;
394 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
395 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
396 | CLANG_WARN_EMPTY_BODY = YES;
397 | CLANG_WARN_ENUM_CONVERSION = YES;
398 | CLANG_WARN_INFINITE_RECURSION = YES;
399 | CLANG_WARN_INT_CONVERSION = YES;
400 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
401 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
402 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
403 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
404 | CLANG_WARN_STRICT_PROTOTYPES = YES;
405 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
406 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
407 | CLANG_WARN_UNREACHABLE_CODE = YES;
408 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
409 | CODE_SIGN_IDENTITY = "iPhone Developer";
410 | COPY_PHASE_STRIP = NO;
411 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
412 | ENABLE_NS_ASSERTIONS = NO;
413 | ENABLE_STRICT_OBJC_MSGSEND = YES;
414 | GCC_C_LANGUAGE_STANDARD = gnu11;
415 | GCC_NO_COMMON_BLOCKS = YES;
416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
418 | GCC_WARN_UNDECLARED_SELECTOR = YES;
419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
420 | GCC_WARN_UNUSED_FUNCTION = YES;
421 | GCC_WARN_UNUSED_VARIABLE = YES;
422 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
423 | MTL_ENABLE_DEBUG_INFO = NO;
424 | SDKROOT = iphoneos;
425 | VALIDATE_PRODUCT = YES;
426 | };
427 | name = Release;
428 | };
429 | 935724BE2032FFBC00850BC9 /* Debug */ = {
430 | isa = XCBuildConfiguration;
431 | buildSettings = {
432 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
433 | CODE_SIGN_STYLE = Automatic;
434 | INFOPLIST_FILE = "YSC-GCD-demo/Info.plist";
435 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
437 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demo";
438 | PRODUCT_NAME = "$(TARGET_NAME)";
439 | TARGETED_DEVICE_FAMILY = "1,2";
440 | };
441 | name = Debug;
442 | };
443 | 935724BF2032FFBC00850BC9 /* Release */ = {
444 | isa = XCBuildConfiguration;
445 | buildSettings = {
446 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
447 | CODE_SIGN_STYLE = Automatic;
448 | INFOPLIST_FILE = "YSC-GCD-demo/Info.plist";
449 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
450 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
451 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demo";
452 | PRODUCT_NAME = "$(TARGET_NAME)";
453 | TARGETED_DEVICE_FAMILY = "1,2";
454 | };
455 | name = Release;
456 | };
457 | 935724C12032FFBC00850BC9 /* Debug */ = {
458 | isa = XCBuildConfiguration;
459 | buildSettings = {
460 | BUNDLE_LOADER = "$(TEST_HOST)";
461 | CODE_SIGN_STYLE = Automatic;
462 | INFOPLIST_FILE = "YSC-GCD-demoTests/Info.plist";
463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
464 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demoTests";
465 | PRODUCT_NAME = "$(TARGET_NAME)";
466 | TARGETED_DEVICE_FAMILY = "1,2";
467 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YSC-GCD-demo.app/YSC-GCD-demo";
468 | };
469 | name = Debug;
470 | };
471 | 935724C22032FFBC00850BC9 /* Release */ = {
472 | isa = XCBuildConfiguration;
473 | buildSettings = {
474 | BUNDLE_LOADER = "$(TEST_HOST)";
475 | CODE_SIGN_STYLE = Automatic;
476 | INFOPLIST_FILE = "YSC-GCD-demoTests/Info.plist";
477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
478 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demoTests";
479 | PRODUCT_NAME = "$(TARGET_NAME)";
480 | TARGETED_DEVICE_FAMILY = "1,2";
481 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YSC-GCD-demo.app/YSC-GCD-demo";
482 | };
483 | name = Release;
484 | };
485 | 935724C42032FFBC00850BC9 /* Debug */ = {
486 | isa = XCBuildConfiguration;
487 | buildSettings = {
488 | CODE_SIGN_STYLE = Automatic;
489 | INFOPLIST_FILE = "YSC-GCD-demoUITests/Info.plist";
490 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
491 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demoUITests";
492 | PRODUCT_NAME = "$(TARGET_NAME)";
493 | TARGETED_DEVICE_FAMILY = "1,2";
494 | TEST_TARGET_NAME = "YSC-GCD-demo";
495 | };
496 | name = Debug;
497 | };
498 | 935724C52032FFBC00850BC9 /* Release */ = {
499 | isa = XCBuildConfiguration;
500 | buildSettings = {
501 | CODE_SIGN_STYLE = Automatic;
502 | INFOPLIST_FILE = "YSC-GCD-demoUITests/Info.plist";
503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
504 | PRODUCT_BUNDLE_IDENTIFIER = "net.bujige.YSC-GCD-demoUITests";
505 | PRODUCT_NAME = "$(TARGET_NAME)";
506 | TARGETED_DEVICE_FAMILY = "1,2";
507 | TEST_TARGET_NAME = "YSC-GCD-demo";
508 | };
509 | name = Release;
510 | };
511 | /* End XCBuildConfiguration section */
512 |
513 | /* Begin XCConfigurationList section */
514 | 9357248C2032FFBB00850BC9 /* Build configuration list for PBXProject "YSC-GCD-demo" */ = {
515 | isa = XCConfigurationList;
516 | buildConfigurations = (
517 | 935724BB2032FFBC00850BC9 /* Debug */,
518 | 935724BC2032FFBC00850BC9 /* Release */,
519 | );
520 | defaultConfigurationIsVisible = 0;
521 | defaultConfigurationName = Release;
522 | };
523 | 935724BD2032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demo" */ = {
524 | isa = XCConfigurationList;
525 | buildConfigurations = (
526 | 935724BE2032FFBC00850BC9 /* Debug */,
527 | 935724BF2032FFBC00850BC9 /* Release */,
528 | );
529 | defaultConfigurationIsVisible = 0;
530 | defaultConfigurationName = Release;
531 | };
532 | 935724C02032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demoTests" */ = {
533 | isa = XCConfigurationList;
534 | buildConfigurations = (
535 | 935724C12032FFBC00850BC9 /* Debug */,
536 | 935724C22032FFBC00850BC9 /* Release */,
537 | );
538 | defaultConfigurationIsVisible = 0;
539 | defaultConfigurationName = Release;
540 | };
541 | 935724C32032FFBC00850BC9 /* Build configuration list for PBXNativeTarget "YSC-GCD-demoUITests" */ = {
542 | isa = XCConfigurationList;
543 | buildConfigurations = (
544 | 935724C42032FFBC00850BC9 /* Debug */,
545 | 935724C52032FFBC00850BC9 /* Release */,
546 | );
547 | defaultConfigurationIsVisible = 0;
548 | defaultConfigurationName = Release;
549 | };
550 | /* End XCConfigurationList section */
551 | };
552 | rootObject = 935724892032FFBB00850BC9 /* Project object */;
553 | }
554 |
--------------------------------------------------------------------------------