├── .DS_Store ├── .gitignore ├── KC大师班考试试卷集合 ├── 2021年大师班第一阶段考试.md └── 2021年大师班第二阶段考试.md ├── README.md ├── iOS_懒人开发技巧 └── CodeSnippets.zip ├── 小专栏-socket篇章代码 ├── 001---Socket初体验 │ ├── .DS_Store │ ├── 001---Socket初体验.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── 001---Socket初体验 │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m ├── 001---Socket初体验服务器 │ ├── .DS_Store │ ├── 001---Socket初体验.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── 001---Socket初体验 │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m ├── 002---GCDAsySocketDemo │ ├── .DS_Store │ ├── 002--GCDAsySocketDemo.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 002--GCDAsySocketDemo.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 002--GCDAsySocketDemo │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ ├── Podfile │ ├── Podfile.lock │ └── Pods │ │ ├── .DS_Store │ │ ├── CocoaAsyncSocket │ │ ├── LICENSE.txt │ │ ├── README.markdown │ │ └── Source │ │ │ └── GCD │ │ │ ├── GCDAsyncSocket.h │ │ │ ├── GCDAsyncSocket.m │ │ │ ├── GCDAsyncUdpSocket.h │ │ │ └── GCDAsyncUdpSocket.m │ │ ├── Manifest.lock │ │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ │ └── Target Support Files │ │ ├── CocoaAsyncSocket │ │ ├── CocoaAsyncSocket-Info.plist │ │ ├── CocoaAsyncSocket-dummy.m │ │ ├── CocoaAsyncSocket-prefix.pch │ │ ├── CocoaAsyncSocket-umbrella.h │ │ ├── CocoaAsyncSocket.debug.xcconfig │ │ ├── CocoaAsyncSocket.modulemap │ │ └── CocoaAsyncSocket.release.xcconfig │ │ └── Pods-002--GCDAsySocketDemo │ │ ├── Pods-002--GCDAsySocketDemo-Info.plist │ │ ├── Pods-002--GCDAsySocketDemo-acknowledgements.markdown │ │ ├── Pods-002--GCDAsySocketDemo-acknowledgements.plist │ │ ├── Pods-002--GCDAsySocketDemo-dummy.m │ │ ├── Pods-002--GCDAsySocketDemo-frameworks-Debug-input-files.xcfilelist │ │ ├── Pods-002--GCDAsySocketDemo-frameworks-Debug-output-files.xcfilelist │ │ ├── Pods-002--GCDAsySocketDemo-frameworks-Release-input-files.xcfilelist │ │ ├── Pods-002--GCDAsySocketDemo-frameworks-Release-output-files.xcfilelist │ │ ├── Pods-002--GCDAsySocketDemo-frameworks.sh │ │ ├── Pods-002--GCDAsySocketDemo-umbrella.h │ │ ├── Pods-002--GCDAsySocketDemo.debug.xcconfig │ │ ├── Pods-002--GCDAsySocketDemo.modulemap │ │ └── Pods-002--GCDAsySocketDemo.release.xcconfig ├── 003---粘包拆包 │ ├── .DS_Store │ ├── 003---粘包拆包.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 003---粘包拆包.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 003---粘包拆包 │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── test.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── 美女测试图片.jpg │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ ├── main.m │ │ └── q1.mp4 │ ├── Podfile.lock │ ├── Pods │ │ ├── .DS_Store │ │ ├── CocoaAsyncSocket │ │ │ ├── LICENSE.txt │ │ │ ├── README.markdown │ │ │ └── Source │ │ │ │ └── GCD │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ ├── GCDAsyncSocket.m │ │ │ │ ├── GCDAsyncUdpSocket.h │ │ │ │ └── GCDAsyncUdpSocket.m │ │ ├── Headers │ │ │ ├── Private │ │ │ │ └── CocoaAsyncSocket │ │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ │ └── GCDAsyncUdpSocket.h │ │ │ └── Public │ │ │ │ └── CocoaAsyncSocket │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ └── GCDAsyncUdpSocket.h │ │ ├── Manifest.lock │ │ ├── Pods.xcodeproj │ │ │ └── project.pbxproj │ │ └── Target Support Files │ │ │ ├── CocoaAsyncSocket │ │ │ ├── CocoaAsyncSocket-dummy.m │ │ │ ├── CocoaAsyncSocket-prefix.pch │ │ │ ├── CocoaAsyncSocket.debug.xcconfig │ │ │ └── CocoaAsyncSocket.release.xcconfig │ │ │ └── Pods-003---粘包拆包 │ │ │ ├── Pods-003---粘包拆包-acknowledgements.markdown │ │ │ ├── Pods-003---粘包拆包-acknowledgements.plist │ │ │ ├── Pods-003---粘包拆包-dummy.m │ │ │ ├── Pods-003---粘包拆包.debug.xcconfig │ │ │ └── Pods-003---粘包拆包.release.xcconfig │ └── podfile ├── 003---粘包拆包服务器 │ ├── .DS_Store │ ├── 003---粘包拆包.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 003---粘包拆包.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 003---粘包拆包 │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── test.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── 美女测试图片.jpg │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ ├── Podfile.lock │ ├── Pods │ │ ├── .DS_Store │ │ ├── CocoaAsyncSocket │ │ │ ├── LICENSE.txt │ │ │ ├── README.markdown │ │ │ └── Source │ │ │ │ └── GCD │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ ├── GCDAsyncSocket.m │ │ │ │ ├── GCDAsyncUdpSocket.h │ │ │ │ └── GCDAsyncUdpSocket.m │ │ ├── Headers │ │ │ ├── Private │ │ │ │ └── CocoaAsyncSocket │ │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ │ └── GCDAsyncUdpSocket.h │ │ │ └── Public │ │ │ │ └── CocoaAsyncSocket │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ └── GCDAsyncUdpSocket.h │ │ ├── Manifest.lock │ │ ├── Pods.xcodeproj │ │ │ └── project.pbxproj │ │ └── Target Support Files │ │ │ ├── CocoaAsyncSocket │ │ │ ├── CocoaAsyncSocket-dummy.m │ │ │ ├── CocoaAsyncSocket-prefix.pch │ │ │ └── CocoaAsyncSocket.xcconfig │ │ │ └── Pods-003---粘包拆包 │ │ │ ├── Pods-003---粘包拆包-acknowledgements.markdown │ │ │ ├── Pods-003---粘包拆包-acknowledgements.plist │ │ │ ├── Pods-003---粘包拆包-dummy.m │ │ │ ├── Pods-003---粘包拆包-frameworks.sh │ │ │ ├── Pods-003---粘包拆包-resources.sh │ │ │ ├── Pods-003---粘包拆包.debug.xcconfig │ │ │ └── Pods-003---粘包拆包.release.xcconfig │ └── podfile ├── 004---画板功能 │ ├── .DS_Store │ ├── 004---画板功能.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 004---画板功能.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── 004---画板功能 │ │ ├── .DS_Store │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── KCView.h │ │ ├── KCView.m │ │ ├── UIBezierPath+point.h │ │ ├── UIBezierPath+point.m │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ ├── Podfile.lock │ ├── Pods │ │ ├── .DS_Store │ │ ├── CocoaAsyncSocket │ │ │ ├── LICENSE.txt │ │ │ ├── README.markdown │ │ │ └── Source │ │ │ │ └── GCD │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ ├── GCDAsyncSocket.m │ │ │ │ ├── GCDAsyncUdpSocket.h │ │ │ │ └── GCDAsyncUdpSocket.m │ │ ├── Headers │ │ │ ├── Private │ │ │ │ └── CocoaAsyncSocket │ │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ │ └── GCDAsyncUdpSocket.h │ │ │ └── Public │ │ │ │ └── CocoaAsyncSocket │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ └── GCDAsyncUdpSocket.h │ │ ├── Manifest.lock │ │ ├── Pods.xcodeproj │ │ │ └── project.pbxproj │ │ └── Target Support Files │ │ │ ├── CocoaAsyncSocket │ │ │ ├── CocoaAsyncSocket-dummy.m │ │ │ ├── CocoaAsyncSocket-prefix.pch │ │ │ └── CocoaAsyncSocket.xcconfig │ │ │ └── Pods-004---画板功能 │ │ │ ├── Pods-004---画板功能-acknowledgements.markdown │ │ │ ├── Pods-004---画板功能-acknowledgements.plist │ │ │ ├── Pods-004---画板功能-dummy.m │ │ │ ├── Pods-004---画板功能-frameworks.sh │ │ │ ├── Pods-004---画板功能-resources.sh │ │ │ ├── Pods-004---画板功能.debug.xcconfig │ │ │ └── Pods-004---画板功能.release.xcconfig │ └── podfile └── 004---画板服务器 │ ├── .DS_Store │ ├── 004---画板服务器.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ ├── 004---画板服务器.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ ├── 004---画板服务器 │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── KCView.h │ ├── KCView.m │ ├── UIBezierPath+point.h │ ├── UIBezierPath+point.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m │ ├── Podfile.lock │ ├── Pods │ ├── .DS_Store │ ├── CocoaAsyncSocket │ │ ├── LICENSE.txt │ │ ├── README.markdown │ │ └── Source │ │ │ └── GCD │ │ │ ├── GCDAsyncSocket.h │ │ │ ├── GCDAsyncSocket.m │ │ │ ├── GCDAsyncUdpSocket.h │ │ │ └── GCDAsyncUdpSocket.m │ ├── Headers │ │ ├── .DS_Store │ │ ├── Private │ │ │ └── CocoaAsyncSocket │ │ │ │ ├── GCDAsyncSocket.h │ │ │ │ └── GCDAsyncUdpSocket.h │ │ └── Public │ │ │ └── CocoaAsyncSocket │ │ │ ├── GCDAsyncSocket.h │ │ │ └── GCDAsyncUdpSocket.h │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ └── Target Support Files │ │ ├── .DS_Store │ │ ├── CocoaAsyncSocket │ │ ├── CocoaAsyncSocket-dummy.m │ │ ├── CocoaAsyncSocket-prefix.pch │ │ └── CocoaAsyncSocket.xcconfig │ │ └── Pods-004---画板服务器 │ │ ├── Pods-004---画板服务器-acknowledgements.markdown │ │ ├── Pods-004---画板服务器-acknowledgements.plist │ │ ├── Pods-004---画板服务器-dummy.m │ │ ├── Pods-004---画板服务器-frameworks.sh │ │ ├── Pods-004---画板服务器-resources.sh │ │ ├── Pods-004---画板服务器.debug.xcconfig │ │ └── Pods-004---画板服务器.release.xcconfig │ └── podfile ├── 资源文件 ├── KC_iOS杂货铺封面.png ├── cooci_QRCode.png └── isa流程图.png └── 面试题集合 ├── 2020-2021年最新面试题收集.md └── 逻辑教育iOS面试题集合.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | # CocoaPods 34 | # 35 | # We recommend against adding the Pods directory to your .gitignore. However 36 | # you should judge for yourself, the pros and cons are mentioned at: 37 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 38 | # 39 | # Pods/ 40 | # 41 | # Add this line if you want to avoid checking in source code from the Xcode workspace 42 | # *.xcworkspace 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build/ 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. 54 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 57 | 58 | fastlane/report.xml 59 | fastlane/Preview.html 60 | fastlane/screenshots/**/*.png 61 | fastlane/test_output 62 | 63 | # Code Injection 64 | # 65 | # After new code Injection tools there's a generated folder /iOSInjectionProject 66 | # https://github.com/johnno1962/injectionforxcode 67 | 68 | iOSInjectionProject/ 69 | -------------------------------------------------------------------------------- /KC大师班考试试卷集合/2021年大师班第一阶段考试.md: -------------------------------------------------------------------------------- 1 | ![](https://upload-images.jianshu.io/upload_images/2257417-c619c40dd47b0d45.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 2 | 3 | ### 考试介绍 4 | 5 | 6 | 最近一直在带大师班,学习有一段时间了带着以下三个目的进行了一场测验.收益颇多.这里也纪录下来 7 | 8 | 🎯 考试检测大家最近的学习 9 | 10 | 🎯 敲响警钟,希望大家能够端正学习态度、及时查漏补缺 11 | 12 | 🎯 根据大家在这阶段学习的情况调整下阶段讲课的速度和深度 13 | 14 | 15 | 正常考试 分为四种题型. 总分 200分 (`不要问我为什么不是100分,诶...就是玩!!!!😸`) 16 | 17 | 18 | * 1、选择题 (每题5分, 共10道 50分) 19 | 20 | * 2、判断题 (每题5分, 共6道 30分) 21 | 22 | * 3、简单题 (每题10分 共10道 100分) 23 | 24 | * 4、拓展满分题 (20分) 25 | 26 | > 下面我就贴出题目吧,如果你有时间的,不妨也拿笔本子测试一下,看看能做多少分,在文章留言我会第一时间发你答案! 或者加我微信: KC_Cooci 27 | 28 | ### 一、选择题(每题5分) ⚠️ 有单选有多选哦⚠️ 29 | 30 | > * 1. 在LP64下,一个指针的有多少个字节  分值5分 31 | 32 | - [ ] A: 4 33 | 34 | - [ ] B: 8 35 | 36 | - [ ] C: 16 37 | 38 | - [ ] D: 64 39 | 40 | 41 | > * 2. 一个实例对象的内存结构存在哪些元素  分值5分 42 | 43 | - [ ] A:成员变量 44 | 45 | - [ ] B: supClass 46 | 47 | - [ ] C: cache_t 48 | 49 | - [ ] D: bit 50 | 51 | 52 | > * 3. 下面`sizeof(struct3)` 大小等于  分值5分 53 | 54 | 55 | ``` 56 | struct LGStruct1 { 57 | char b; 58 | int c; 59 | double a; 60 | short d; 61 | }struct1; 62 | 63 | struct LGStruct2 { 64 | double a; 65 | int b; 66 | char c; 67 | short d; 68 | }struct2; 69 | 70 | 71 | struct LGStruct3 { 72 | double a; 73 | int b; 74 | char c; 75 | struct LGStruct1 str1; 76 | short d; 77 | int e; 78 | struct LGStruct2 str2; 79 | }struct3; 80 | ``` 81 | 82 | - [ ] A: 48 83 | 84 | - [ ] B: 56 85 | 86 | - [ ] C: 64 87 | 88 | - [ ] D: 72 89 | 90 | > * 4. 下列代码: `re1 re2 re3 re4 re5 re6 re7` re8输出结果  分值5分 91 | 92 | ``` 93 | BOOL re1 = [(id)[NSObject class] isKindOfClass:[NSObject class]]; 94 | BOOL re2 = [(id)[NSObject class] isMemberOfClass:[NSObject class]]; 95 | BOOL re3 = [(id)[LGPerson class] isKindOfClass:[LGPerson class]]; 96 | BOOL re4 = [(id)[LGPerson class] isMemberOfClass:[LGPerson class]]; 97 | NSLog(@" re1 :%hhd\n re2 :%hhd\n re3 :%hhd\n re4 :%hhd\n",re1,re2,re3,re4); 98 | 99 | BOOL re5 = [(id)[NSObject alloc] isKindOfClass:[NSObject class]]; 100 | BOOL re6 = [(id)[NSObject alloc] isMemberOfClass:[NSObject class]]; 101 | BOOL re7 = [(id)[LGPerson alloc] isKindOfClass:[LGPerson class]]; 102 | BOOL re8 = [(id)[LGPerson alloc] isMemberOfClass:[LGPerson class]]; 103 | NSLog(@" re5 :%hhd\n re6 :%hhd\n re7 :%hhd\n re8 :%hhd\n",re5,re6,re7,re8); 104 | ``` 105 | 106 | 107 | - [ ] A: 1011 1111 108 | 109 | - [ ] B: 1100 1011 110 | 111 | - [ ] C: 1000 1111 112 | 113 | - [ ] D: 1101 1111 114 | 115 | > * 5. `(x + 7) & ~7` 这个算法是几字节对齐  分值5分 116 | 117 | - [ ] A: 7 118 | 119 | - [ ] B: 8 120 | 121 | - [ ] C: 14 122 | 123 | - [ ] D: 16 124 | 125 | 126 | > * 6. 判断下列数据结构大小  分值5分 127 | 128 | ``` 129 | union kc_t { 130 | uintptr_t bits; 131 | struct { 132 | int a; 133 | char b; 134 | }; 135 | } 136 | ``` 137 | 138 | - [ ] A: 8 139 | 140 | - [ ] B: 12 141 | 142 | - [ ] C: 13 143 | 144 | - [ ] D: 16 145 | 146 | 147 | > * 7. 元类的 isa 指向谁, 根元类的父类是谁  分值5分 148 | 149 | - [ ] A: 自己 , 根元类 150 | 151 | - [ ] B: 自己 , NSObject 152 | 153 | - [ ] C: 根元类 , 根元类 154 | 155 | - [ ] D: 根元类 , NSObject 156 | 157 | > * 8. 查找方法缓存的时候发现是乱序的, 为什么? 哈希冲突怎么解决的  分值5分 158 | 159 | - [ ] A: 哈希函数原因 , 不解决 160 | 161 | - [ ] B: 哈希函数原因 , 再哈希 162 | 163 | - [ ] C: 他存他的我也布吉岛 , 再哈希 164 | 165 | - [ ] D: 他乱由他乱,清风过山岗 , 不解决 166 | 167 | 168 | > * 9. 消息的流程是  分值5分 169 | 170 | - [ ] A: 先从缓存快速查找 171 | 172 | - [ ] B: 慢速递归查找methodlist (自己的和父类的,直到父类为nil) 173 | 174 | - [ ] C: 动态方法决议 175 | 176 | - [ ] D: 消息转发流程 177 | 178 | 179 | > * 10. 类方法动态方法决议为什么在后面还要实现 `resolveInstanceMethod`   分值5分 180 | 181 | - [ ] A: 类方法存在元类(以对象方法形式存在), 元类的父类最终是 `NSObject` 所以我们可以通过`resolveInstanceMethod` 防止 `NSObject` 中实现了对象方法! 182 | 183 | - [ ] B: 因为在oc的底层最终还是对象方法存在 184 | 185 | - [ ] C: 类方法存在元类以对象方法形式存在. 186 | 187 | - [ ] D: 咸吃萝卜,淡操心! 苹果瞎写的 不用管 188 | 189 | ### 二、判断题 (每题5分) 190 | 191 | > * 11. 光凭我们的对象地址,无法确认对象是否存在关联对象  分值5分 192 | 193 | - [ ] 对 194 | - [ ] 错 195 | 196 | 197 | > * 12. `int c[4] = {1,2,3,4}; int *d = c; c[2] = *(d+2)`  分值5分 198 | 199 | - [ ] 对 200 | - [ ] 错 201 | 202 | 203 | > * 13. `@interface LGPerson : NSObject{ UIButton *btn }` 其中 `btn` 是实例变量  分值5分 204 | 205 | - [ ] 对 206 | - [ ] 错 207 | 208 | > * 14. `NSObject` 除外 元类的父类 = 父类的元类  分值5分 209 | 210 | - [ ] 对 211 | - [ ] 错 212 | 213 | > * 15. 对象的地址就是内存元素的首地址  分值5分 214 | 215 | - [ ] 对 216 | - [ ] 错 217 | 218 | > * 16. 类也是对象  分值5分 219 | 220 | - [ ] 对 221 | - [ ] 错 222 | 223 | ### 三、简单题 (每题 10分 合计 100分) 224 | 225 | **请把它当成一场面试,认真对待 希望大家耐心 切忌浮躁 (和谐学习 不急不躁)** 226 | 227 | * 17、怎么将上层OC代码还原成 `C++`代码  分值10分 228 | 229 | * 18、怎么打开汇编查看流程,有什么好处 ?  分值10分 230 | 231 | * 19、`x/4gx` 和 `p/x` 以及 `p *$0` 代表什么意思  分值10分 232 | 233 | * 20、类方法存在哪里? 为什么要这么设计?  分值10分 234 | 235 | * 21、方法慢速查找过程中的二分查找流程,请用伪代码实现 分值10分 236 | 237 | * 22、`ISA_MASK = 0x00007ffffffffff8ULL` 那么这个 `ISA_MASK` 的算法意义是什么?  分值10分 238 | 239 | * 23、类的结构里面为什么会有 `rw` 和 `ro` 以及 `rwe` ?  分值10分 240 | 241 | * 24、`cache` 在什么时候开始扩容 , 为什么?  分值10分 242 | 243 | * 25、`objc_msgSend` 为什么用汇编写 , `objc_msgSend` 是如何递归找到imp?  分值10分 244 | 245 | * 26、一个类的类方法没有实现为什么可以调用 `NSObject` 同名对象方法  分值10分 246 | 247 | 248 | ### 四、拓展满分题 (20分 249 | 250 | 27. 提交一篇大师班学习期间,你写的最好的一篇博客  分值20分 251 | 252 | 253 | ### 五、总结 254 | 255 | 考试的题目偏向底层, 也比较贴合现在iOS的面试市场! 内容有深有浅,还可以继续挖坑 (👀) 256 | 257 | > 声明: 内容只是为了促进学习,并不是为行业增加内卷.希望各位靓仔靓女 不要把这些题目作为面试素材为难求职者.答案可以直接微信我: KC_Cooci 258 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KCiOSGrocery - iOS杂货铺 2 | 3 | ![](https://github.com/LGCooci/LGiOSQuestions/blob/master/资源文件/KC_iOS杂货铺封面.png) 4 | 5 | 这个仓库总结一些乱七八糟东西 6 | * `iOS中高级面试题` 7 | * `我VIP大师班分享出来的考试试卷` 8 | * `iOS_懒人开发tips` 9 | * 如果大家可以通过点赞小心心,收藏方便下次查阅 **Star** 走一波.... Thanks♪(・ω・)ノ 10 | 11 | **⚠️特别说明:部分来源网络摘抄,如有疑问,立即删除!⚠️** 12 | 13 | > 本人博客地址:[Cooci-掘金](https://juejin.im/user/5c3f3c415188252b7d0ea40c) 14 | > 15 | > 有一起加入同步更新这个仓库的小伙伴,请微信我 16 | > 17 | > [1: 逻辑教育iOS面试题集合 (2020-06-22)](https://github.com/LGCooci/LGiOSQuestions/blob/master/面试题集合/2020-逻辑教育iOS面试题集合.md) 18 | > 19 | > [2: 2020-2021年最新面试题收集 (2021-04-27)](https://github.com/LGCooci/LGiOSQuestions/blob/master/面试题集合/2020-2021年最新面试题收集.md) 八套题你掌握直接起飞 20 | > 21 | > [3: 2021年逻辑教育大师班第1次考试 (2021-08-13)](https://github.com/LGCooci/LGiOSQuestions/blob/master/KC大师班考试试卷集合/2021年大师班第一阶段考试.md) 22 | > 23 | > [4: 2021年逻辑教育大师班第2次考试 (2021-09-07)](https://github.com/LGCooci/LGiOSQuestions/blob/master/KC大师班考试试卷集合/2021年大师班第一阶段考试.md) 24 | 25 | 这个专栏持续更新中,因为一个人更新整理,所以有很地方会有不对! 如果靓仔靓女的你发现了,请及时留言更新, 优化整个生态从你的一个小爱心 (❤️) 开始 26 | 27 | **我还是我,颜色不一样的烟火! 我是Cooci,期待与你更好的相遇** 28 | 29 | [**☎️ : KC_Cooci 联系方式**](https://github.com/LGCooci/LGiOSQuestions/blob/master/资源文件/cooci_QRCode.png) 30 | -------------------------------------------------------------------------------- /iOS_懒人开发技巧/CodeSnippets.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/iOS_懒人开发技巧/CodeSnippets.zip -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/001---Socket初体验/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/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 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验/001---Socket初体验/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/001---Socket初体验服务器/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/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 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 47 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "ViewController.h" 9 | #import 10 | #import 11 | #import 12 | 13 | #define SocketPort htons(8040) 14 | #define SocketIP inet_addr("127.0.0.1") 15 | 16 | static int const kMaxConnectCount = 5; 17 | 18 | @interface ViewController () 19 | @property (nonatomic, assign) int serverId; 20 | @property (weak, nonatomic) IBOutlet UITextField *sendMsgContent_tf; 21 | @property (nonatomic, strong) NSMutableAttributedString *totalAttributeStr; 22 | @property (nonatomic, copy) NSString *recoderTime; 23 | @property (nonatomic, assign) int client_socket; 24 | 25 | @end 26 | 27 | @implementation ViewController 28 | 29 | - (void)viewDidLoad { 30 | [super viewDidLoad]; 31 | 32 | } 33 | 34 | #pragma mark - 创建socket建立连接 35 | - (IBAction)socketConnetAction:(UIButton *)sender { 36 | 37 | // 1: 创建socket 38 | self.serverId = socket(AF_INET, SOCK_STREAM, 0); 39 | 40 | if (self.serverId == -1) { 41 | NSLog(@"创建socket 失败"); 42 | return; 43 | } 44 | NSLog(@"创建socket 成功"); 45 | 46 | struct sockaddr_in socketAddr; 47 | socketAddr.sin_family = AF_INET; 48 | socketAddr.sin_port = SocketPort; 49 | struct in_addr socketIn_addr; 50 | socketIn_addr.s_addr = SocketIP; 51 | socketAddr.sin_addr = socketIn_addr; 52 | bzero(&(socketAddr.sin_zero), 8); 53 | 54 | // 2: 绑定socket 55 | int bind_result = bind(self.serverId, (const struct sockaddr *)&socketAddr, sizeof(socketAddr)); 56 | if (bind_result == -1) { 57 | NSLog(@"绑定socket 失败"); 58 | return; 59 | } 60 | 61 | NSLog(@"绑定socket成功"); 62 | 63 | // 3: 监听socket 64 | int listen_result = listen(self.serverId, kMaxConnectCount); 65 | if (listen_result == -1) { 66 | NSLog(@"监听失败"); 67 | return; 68 | } 69 | 70 | NSLog(@"监听成功"); 71 | // 4: 接受客户端的链接 72 | for (int i = 0; i < kMaxConnectCount; i++) { 73 | [self acceptClientConnet]; 74 | } 75 | 76 | } 77 | 78 | #pragma mark - 接受客户端的链接 79 | 80 | - (void)acceptClientConnet{ 81 | 82 | // 阻塞线程 83 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 84 | struct sockaddr_in client_address; 85 | socklen_t address_len; 86 | // accept函数 87 | int client_socket = accept(self.serverId, (struct sockaddr *)&client_address, &address_len); 88 | self.client_socket = client_socket; 89 | 90 | if (client_socket == -1) { 91 | NSLog(@"接受 %u 客户端错误",address_len); 92 | 93 | }else{ 94 | NSString *acceptInfo = [NSString stringWithFormat:@"客户端 in,socket:%d",client_socket]; 95 | NSLog(@"%@",acceptInfo); 96 | [self receiveMsgWithClietnSocket:client_socket]; 97 | } 98 | 99 | }); 100 | 101 | } 102 | 103 | - (void)receiveMsgWithClietnSocket:(int)clientSocket{ 104 | while (1) { 105 | // 5: 接受客户端传来的数据 106 | char buf[1024] = {0}; 107 | long iReturn = recv(clientSocket, buf, 1024, 0); 108 | if (iReturn>0) { 109 | NSLog(@"客户端来消息了"); 110 | // 接收到的数据转换 111 | NSData *recvData = [NSData dataWithBytes:buf length:iReturn]; 112 | NSString *recvStr = [[NSString alloc] initWithData:recvData encoding:NSUTF8StringEncoding]; 113 | NSLog(@"%@",recvStr); 114 | 115 | }else if (iReturn == -1){ 116 | NSLog(@"读取消息失败"); 117 | break; 118 | }else if (iReturn == 0){ 119 | NSLog(@"客户端走了"); 120 | 121 | close(clientSocket); 122 | 123 | break; 124 | } 125 | } 126 | } 127 | 128 | #pragma mark - socket 发送消息 129 | 130 | - (IBAction)didClickSendAction:(id)sender { 131 | 132 | // 6: 发送消息 133 | const char *msg = self.sendMsgContent_tf.text.UTF8String; 134 | ssize_t sendLen = send(self.client_socket, msg, strlen(msg), 0); 135 | NSLog(@"发送了:%ld字节",sendLen); 136 | self.sendMsgContent_tf.text = @""; 137 | } 138 | 139 | #pragma mark - socket 发送消息 140 | - (IBAction)didClickCloseAction:(id)sender { 141 | // 7: 关闭socket连接 142 | int close_result = close(self.client_socket); 143 | 144 | if (close_result == -1) { 145 | NSLog(@"socket 关闭失败"); 146 | return; 147 | }else{ 148 | NSLog(@"socket 关闭成功"); 149 | } 150 | } 151 | 152 | 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/001---Socket初体验服务器/001---Socket初体验/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 001---Socket初体验 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/002---GCDAsySocketDemo/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 002--GCDAsySocketDemo 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 002--GCDAsySocketDemo 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 002--GCDAsySocketDemo 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 002--GCDAsySocketDemo 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "ViewController.h" 9 | #import 10 | 11 | @interface ViewController () 12 | @property (weak, nonatomic) IBOutlet UITextField *contentTF; 13 | @property (nonatomic, strong) GCDAsyncSocket *socket; 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | } 22 | 23 | #pragma mark - 连接socket 24 | - (IBAction)didClickConnectSocket:(id)sender { 25 | // 创建socket 26 | if (self.socket == nil) 27 | self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(0, 0)]; 28 | // 连接socket 29 | if (!self.socket.isConnected){ 30 | NSError *error; 31 | [self.socket connectToHost:@"127.0.0.1" onPort:8090 withTimeout:-1 error:&error]; 32 | if (error) NSLog(@"%@",error); 33 | } 34 | 35 | } 36 | 37 | #pragma mark - 发送 38 | - (IBAction)didClickSendAction:(id)sender { 39 | 40 | NSData *data = [self.contentTF.text dataUsingEncoding:NSUTF8StringEncoding]; 41 | [self.socket writeData:data withTimeout:-1 tag:10086]; 42 | } 43 | 44 | #pragma mark - 重连 45 | - (IBAction)didClickReconnectAction:(id)sender { 46 | // 创建socket 47 | if (self.socket == nil) 48 | self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(0, 0)]; 49 | // 连接socket 50 | if (!self.socket.isConnected){ 51 | NSError *error; 52 | [self.socket connectToHost:@"127.0.0.1" onPort:8090 withTimeout:-1 error:&error]; 53 | if (error) NSLog(@"%@",error); 54 | } 55 | } 56 | 57 | #pragma mark - 关闭socket 58 | - (IBAction)didClickCloseAction:(id)sender { 59 | [self.socket disconnect]; 60 | self.socket = nil; 61 | } 62 | 63 | #pragma mark - GCDAsyncSocketDelegate 64 | 65 | //已经连接到服务器 66 | - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(nonnull NSString *)host port:(uint16_t)port{ 67 | 68 | NSLog(@"连接成功 : %@---%d",host,port); 69 | [self.socket readDataWithTimeout:-1 tag:10086]; 70 | } 71 | 72 | // 连接断开 73 | - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err{ 74 | NSLog(@"断开 socket连接 原因:%@",err); 75 | } 76 | 77 | //已经接收服务器返回来的数据 78 | - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag{ 79 | NSLog(@"接收到tag = %ld : %ld 长度的数据:%@",tag,data.length-1,[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); 80 | [self.socket readDataWithTimeout:-1 tag:10086]; 81 | } 82 | 83 | //消息发送成功 代理函数 向服务器 发送消息 84 | - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag{ 85 | NSLog(@"%ld 发送数据成功",tag); 86 | } 87 | 88 | 89 | - (void)didReceiveMemoryWarning { 90 | [super didReceiveMemoryWarning]; 91 | // Dispose of any resources that can be recreated. 92 | } 93 | 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/002--GCDAsySocketDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 002--GCDAsySocketDemo 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target '002--GCDAsySocketDemo' do 5 | # Comment the next line if you don't want to use dynamic frameworks 6 | use_frameworks! 7 | pod 'CocoaAsyncSocket' 8 | # Pods for 002--GCDAsySocketDemo 9 | 10 | end 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.4) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 13 | 14 | PODFILE CHECKSUM: 0022f1fa630e448cc1fa8e65b27800327c7a8140 15 | 16 | COCOAPODS: 1.10.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/CocoaAsyncSocket/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This library is in the public domain. 2 | However, not all organizations are allowed to use such a license. 3 | For example, Germany doesn't recognize the Public Domain and one is not allowed to use libraries under such license (or similar). 4 | 5 | Thus, the library is now dual licensed, 6 | and one is allowed to choose which license they would like to use. 7 | 8 | ################################################## 9 | License Option #1 : 10 | ################################################## 11 | 12 | Public Domain 13 | 14 | ################################################## 15 | License Option #2 : 16 | ################################################## 17 | 18 | Software License Agreement (BSD License) 19 | 20 | Copyright (c) 2017, Deusty, LLC 21 | All rights reserved. 22 | 23 | Redistribution and use of this software in source and binary forms, 24 | with or without modification, are permitted provided that the following conditions are met: 25 | 26 | * Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | 30 | * Neither the name of Deusty LLC nor the names of its 31 | contributors may be used to endorse or promote products 32 | derived from this software without specific prior 33 | written permission of Deusty LLC. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.4) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 13 | 14 | PODFILE CHECKSUM: 0022f1fa630e448cc1fa8e65b27800327c7a8140 15 | 16 | COCOAPODS: 1.10.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 7.6.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaAsyncSocket : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaAsyncSocket 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "GCDAsyncSocket.h" 14 | #import "GCDAsyncUdpSocket.h" 15 | 16 | FOUNDATION_EXPORT double CocoaAsyncSocketVersionNumber; 17 | FOUNDATION_EXPORT const unsigned char CocoaAsyncSocketVersionString[]; 18 | 19 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.modulemap: -------------------------------------------------------------------------------- 1 | framework module CocoaAsyncSocket { 2 | umbrella header "CocoaAsyncSocket-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## CocoaAsyncSocket 5 | 6 | Public Domain License 7 | 8 | The CocoaAsyncSocket project is in the public domain. 9 | 10 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 11 | Updated and maintained by Deusty LLC and the Apple development community. 12 | 13 | Generated by CocoaPods - https://cocoapods.org 14 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Public Domain License 18 | 19 | The CocoaAsyncSocket project is in the public domain. 20 | 21 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 22 | Updated and maintained by Deusty LLC and the Apple development community. 23 | 24 | License 25 | public domain 26 | Title 27 | CocoaAsyncSocket 28 | Type 29 | PSGroupSpecifier 30 | 31 | 32 | FooterText 33 | Generated by CocoaPods - https://cocoapods.org 34 | Title 35 | 36 | Type 37 | PSGroupSpecifier 38 | 39 | 40 | StringsTable 41 | Acknowledgements 42 | Title 43 | Acknowledgements 44 | 45 | 46 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_002__GCDAsySocketDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_002__GCDAsySocketDemo 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks-Debug-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks-Debug-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaAsyncSocket.framework -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks-Release-input-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${PODS_ROOT}/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks.sh 2 | ${BUILT_PRODUCTS_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-frameworks-Release-output-files.xcfilelist: -------------------------------------------------------------------------------- 1 | ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaAsyncSocket.framework -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_002__GCDAsySocketDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_002__GCDAsySocketDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "CFNetwork" -framework "CocoaAsyncSocket" -framework "Security" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_002__GCDAsySocketDemo { 2 | umbrella header "Pods-002--GCDAsySocketDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/002---GCDAsySocketDemo/Pods/Target Support Files/Pods-002--GCDAsySocketDemo/Pods-002--GCDAsySocketDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "CFNetwork" -framework "CocoaAsyncSocket" -framework "Security" 7 | PODS_BUILD_DIR = ${BUILD_DIR} 8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/Assets.xcassets/test.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "美女测试图片.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/Assets.xcassets/test.imageset/美女测试图片.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/Assets.xcassets/test.imageset/美女测试图片.jpg -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/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 | 32 | 43 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/q1.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包/003---粘包拆包/q1.mp4 -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.4) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 13 | 14 | PODFILE CHECKSUM: f69ce38f4d7e9457ebb26c771c7caa57f86b40a3 15 | 16 | COCOAPODS: 1.10.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包/Pods/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/CocoaAsyncSocket/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This library is in the public domain. 2 | However, not all organizations are allowed to use such a license. 3 | For example, Germany doesn't recognize the Public Domain and one is not allowed to use libraries under such license (or similar). 4 | 5 | Thus, the library is now dual licensed, 6 | and one is allowed to choose which license they would like to use. 7 | 8 | ################################################## 9 | License Option #1 : 10 | ################################################## 11 | 12 | Public Domain 13 | 14 | ################################################## 15 | License Option #2 : 16 | ################################################## 17 | 18 | Software License Agreement (BSD License) 19 | 20 | Copyright (c) 2017, Deusty, LLC 21 | All rights reserved. 22 | 23 | Redistribution and use of this software in source and binary forms, 24 | with or without modification, are permitted provided that the following conditions are met: 25 | 26 | * Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | 30 | * Neither the name of Deusty LLC nor the names of its 31 | contributors may be used to endorse or promote products 32 | derived from this software without specific prior 33 | written permission of Deusty LLC. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.4) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 13 | 14 | PODFILE CHECKSUM: f69ce38f4d7e9457ebb26c771c7caa57f86b40a3 15 | 16 | COCOAPODS: 1.10.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaAsyncSocket : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaAsyncSocket 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaAsyncSocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaAsyncSocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## CocoaAsyncSocket 5 | 6 | Public Domain License 7 | 8 | The CocoaAsyncSocket project is in the public domain. 9 | 10 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 11 | Updated and maintained by Deusty LLC and the Apple development community. 12 | 13 | Generated by CocoaPods - https://cocoapods.org 14 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Public Domain License 18 | 19 | The CocoaAsyncSocket project is in the public domain. 20 | 21 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 22 | Updated and maintained by Deusty LLC and the Apple development community. 23 | 24 | License 25 | public domain 26 | Title 27 | CocoaAsyncSocket 28 | Type 29 | PSGroupSpecifier 30 | 31 | 32 | FooterText 33 | Generated by CocoaPods - https://cocoapods.org 34 | Title 35 | 36 | Type 37 | PSGroupSpecifier 38 | 39 | 40 | StringsTable 41 | Acknowledgements 42 | Title 43 | Acknowledgements 44 | 45 | 46 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_003_______ : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_003_______ 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包.release.xcconfig: -------------------------------------------------------------------------------- 1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 4 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包/podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target '003---粘包拆包' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | # use_frameworks! 7 | pod 'CocoaAsyncSocket', '~> 7.6.3' 8 | 9 | # Pods for 003---粘包拆包 10 | 11 | end 12 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包服务器/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/Assets.xcassets/test.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "美女测试图片.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/Assets.xcassets/test.imageset/美女测试图片.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/Assets.xcassets/test.imageset/美女测试图片.jpg -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPhotoLibraryAddUsageDescription 6 | 访问相册 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/003---粘包拆包/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 003---粘包拆包 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: f69ce38f4d7e9457ebb26c771c7caa57f86b40a3 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/003---粘包拆包服务器/Pods/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/CocoaAsyncSocket/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This library is in the public domain. 2 | However, not all organizations are allowed to use such a license. 3 | For example, Germany doesn't recognize the Public Domain and one is not allowed to use libraries under such license (or similar). 4 | 5 | Thus, the library is now dual licensed, 6 | and one is allowed to choose which license they would like to use. 7 | 8 | ################################################## 9 | License Option #1 : 10 | ################################################## 11 | 12 | Public Domain 13 | 14 | ################################################## 15 | License Option #2 : 16 | ################################################## 17 | 18 | Software License Agreement (BSD License) 19 | 20 | Copyright (c) 2017, Deusty, LLC 21 | All rights reserved. 22 | 23 | Redistribution and use of this software in source and binary forms, 24 | with or without modification, are permitted provided that the following conditions are met: 25 | 26 | * Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | 30 | * Neither the name of Deusty LLC nor the names of its 31 | contributors may be used to endorse or promote products 32 | derived from this software without specific prior 33 | written permission of Deusty LLC. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: f69ce38f4d7e9457ebb26c771c7caa57f86b40a3 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaAsyncSocket : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaAsyncSocket 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaAsyncSocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 4 | OTHER_LDFLAGS = -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## CocoaAsyncSocket 5 | 6 | Public Domain License 7 | 8 | The CocoaAsyncSocket project is in the public domain. 9 | 10 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 11 | Updated and maintained by Deusty LLC and the Apple development community. 12 | 13 | Generated by CocoaPods - https://cocoapods.org 14 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Public Domain License 18 | 19 | The CocoaAsyncSocket project is in the public domain. 20 | 21 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 22 | Updated and maintained by Deusty LLC and the Apple development community. 23 | 24 | License 25 | public domain 26 | Title 27 | CocoaAsyncSocket 28 | Type 29 | PSGroupSpecifier 30 | 31 | 32 | FooterText 33 | Generated by CocoaPods - https://cocoapods.org 34 | Title 35 | 36 | Type 37 | PSGroupSpecifier 38 | 39 | 40 | StringsTable 41 | Acknowledgements 42 | Title 43 | Acknowledgements 44 | 45 | 46 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_003_______ : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_003_______ 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/Pods/Target Support Files/Pods-003---粘包拆包/Pods-003---粘包拆包.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/003---粘包拆包服务器/podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target '003---粘包拆包' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | # use_frameworks! 7 | pod 'CocoaAsyncSocket', '~> 7.6.3' 8 | 9 | # Pods for 003---粘包拆包 10 | 11 | end 12 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板功能/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板功能/004---画板功能/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 004---画板功能 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 004---画板功能 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/KCView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KCView.h 3 | // 004---画板服务器 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | 7 | #import 8 | 9 | typedef void(^OnePathEndBlock)(NSMutableDictionary *dict); 10 | 11 | @interface KCView : UIView 12 | 13 | //当前正在绘制的贝塞尔曲线 14 | @property (strong, nonatomic) UIBezierPath *currentPath; 15 | // 总的贝塞尔曲线合集 16 | @property (strong, nonatomic) NSMutableArray *pathArray; 17 | // 贝塞尔曲线线条颜色 HEX 18 | @property (copy, nonatomic) NSString *lineColor; 19 | // 贝塞尔曲线线条宽度 20 | @property (assign, nonatomic) CGFloat lineWidth; 21 | //一条贝塞尔曲线绘制完成后的回调Block 22 | @property (copy, nonatomic) OnePathEndBlock onePathEndBlock; 23 | 24 | - (void)dealwithData:(UIBezierPath *)path lineColor:(NSString *)lineColor lineWidth:(CGFloat)lineWidth; 25 | @end 26 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/KCView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KCView.m 3 | // 004---画板服务器 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | 7 | #import "KCView.h" 8 | 9 | @implementation KCView 10 | 11 | #pragma mark -- init Method 12 | 13 | - (instancetype)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | [self setup]; 18 | } 19 | return self; 20 | } 21 | 22 | - (void)awakeFromNib{ 23 | [super awakeFromNib]; 24 | [self setup]; 25 | } 26 | 27 | 28 | - (void)setup{ 29 | _lineColor = @"0xFF0000"; 30 | _lineWidth = 5; 31 | } 32 | 33 | #pragma mark - drawRect 34 | 35 | - (void)drawRect:(CGRect)rect { 36 | 37 | if (self.pathArray.count) { 38 | for (NSMutableDictionary *dict in self.pathArray) { 39 | UIBezierPath *path = dict[@"drawPath"]; 40 | NSString *lineColor = dict[@"lineColor"]; 41 | CGFloat lineWidth = [dict[@"lineWidth"] floatValue]; 42 | [[self colorWithHexString:lineColor] set]; 43 | path.lineWidth = lineWidth; 44 | [path stroke]; 45 | } 46 | } 47 | } 48 | 49 | #pragma mark -- UIView Touch Action 50 | 51 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 52 | //获取起始坐标 53 | CGPoint startPoint = [self getCurrentPointWithTouches:[event allTouches]]; 54 | //初始化 55 | UIBezierPath *tempPath = [UIBezierPath bezierPath]; 56 | //绘制第一个点 57 | [tempPath moveToPoint:startPoint]; 58 | //设置线条风格 59 | tempPath.lineCapStyle = kCGLineCapRound; 60 | //设置连接处效果 61 | tempPath.lineJoinStyle = kCGLineJoinRound; 62 | tempPath.lineWidth = _lineWidth; 63 | _currentPath = tempPath; 64 | 65 | [self dealwithData:tempPath lineColor:_lineColor lineWidth:_lineWidth]; 66 | } 67 | 68 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 69 | //获取坐标 70 | CGPoint movePoint = [self getCurrentPointWithTouches:[event allTouches]]; 71 | //填充图形 72 | [_currentPath addLineToPoint:movePoint]; 73 | [self setNeedsDisplay]; 74 | } 75 | 76 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 77 | //一条线完成之后回调 78 | if (self.onePathEndBlock) { 79 | self.onePathEndBlock([self.pathArray lastObject]); 80 | } 81 | } 82 | 83 | - (CGPoint)getCurrentPointWithTouches:(NSSet *)touches{ 84 | //视图中的所有对象 85 | UITouch *touch = [touches anyObject]; 86 | //返回触摸点在视图中的坐标 87 | return [touch locationInView:touch.view]; 88 | } 89 | 90 | #pragma mark - 数据处理 91 | 92 | - (void)dealwithData:(UIBezierPath *)path lineColor:(NSString *)lineColor lineWidth:(CGFloat)lineWidth{ 93 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1]; 94 | [dict setValue:lineColor forKey:@"lineColor"]; 95 | [dict setValue:path forKey:@"drawPath"]; 96 | [dict setValue:@(lineWidth) forKey:@"lineWidth"]; 97 | [self.pathArray addObject:dict]; 98 | } 99 | 100 | 101 | #pragma mark -- Getter And Setter 102 | 103 | - (void)setLineColor:(NSString *)lineColor{ 104 | _lineColor = lineColor; 105 | } 106 | 107 | - (void)setLineWidth:(CGFloat)lineWidth{ 108 | _lineWidth = lineWidth; 109 | } 110 | 111 | - (NSMutableArray *)pathArray{ 112 | if (!_pathArray) { 113 | _pathArray = [NSMutableArray arrayWithCapacity:0]; 114 | } 115 | return _pathArray; 116 | } 117 | 118 | 119 | - (UIColor *) colorWithHexString: (NSString *) hexString 120 | { 121 | NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; 122 | CGFloat alpha, red, blue, green; 123 | switch ([colorString length]) { 124 | case 3: // #RGB 125 | alpha = 1.0f; 126 | red = [self colorComponentFrom: colorString start: 0 length: 1]; 127 | green = [self colorComponentFrom: colorString start: 1 length: 1]; 128 | blue = [self colorComponentFrom: colorString start: 2 length: 1]; 129 | break; 130 | case 4: // #ARGB 131 | alpha = [self colorComponentFrom: colorString start: 0 length: 1]; 132 | red = [self colorComponentFrom: colorString start: 1 length: 1]; 133 | green = [self colorComponentFrom: colorString start: 2 length: 1]; 134 | blue = [self colorComponentFrom: colorString start: 3 length: 1]; 135 | break; 136 | case 6: // #RRGGBB 137 | alpha = 1.0f; 138 | red = [self colorComponentFrom: colorString start: 0 length: 2]; 139 | green = [self colorComponentFrom: colorString start: 2 length: 2]; 140 | blue = [self colorComponentFrom: colorString start: 4 length: 2]; 141 | break; 142 | case 8: // #AARRGGBB 143 | alpha = [self colorComponentFrom: colorString start: 0 length: 2]; 144 | red = [self colorComponentFrom: colorString start: 2 length: 2]; 145 | green = [self colorComponentFrom: colorString start: 4 length: 2]; 146 | blue = [self colorComponentFrom: colorString start: 6 length: 2]; 147 | break; 148 | default: 149 | blue=0; 150 | green=0; 151 | red=0; 152 | alpha=0; 153 | break; 154 | } 155 | return [UIColor colorWithRed: red green: green blue: blue alpha: 1]; 156 | } 157 | 158 | - (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length 159 | { 160 | NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; 161 | NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; 162 | unsigned hexComponent; 163 | [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; 164 | return hexComponent ; 165 | } 166 | 167 | @end 168 | 169 | 170 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/UIBezierPath+point.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UIBezierPath (point) 5 | /*! 6 | @method  获得UIBezierPath曲线上的所有点坐标 7 | @abstract 获得UIBezierPath曲线上的所有点坐标 8 | @result 坐标点数组 9 | */ 10 | - (NSArray *)points; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/UIBezierPath+point.m: -------------------------------------------------------------------------------- 1 | #import "UIBezierPath+point.h" 2 | 3 | @implementation UIBezierPath (point) 4 | 5 | #define VALUE(_INDEX_) [NSValue valueWithCGPoint:points[_INDEX_]] 6 | 7 | void getPointsFromBezier(void *info,const CGPathElement *element){ 8 | 9 | NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info; 10 | CGPathElementType type = element->type; 11 | CGPoint *points = element->points; 12 | 13 | if (type != kCGPathElementCloseSubpath) { 14 | [bezierPoints addObject:VALUE(0)]; 15 | if ((type != kCGPathElementAddLineToPoint) && (type != kCGPathElementMoveToPoint)) { 16 | [bezierPoints addObject:VALUE(1)]; 17 | } 18 | } 19 | 20 | if (type == kCGPathElementAddCurveToPoint) { 21 | [bezierPoints addObject:VALUE(2)]; 22 | } 23 | } 24 | /*! 25 | @method  获得UIBezierPath曲线上的所有点坐标 26 | @abstract 获得UIBezierPath曲线上的所有点坐标 27 | @result 坐标点数组 28 | */ 29 | - (NSArray *)points 30 | { 31 | NSMutableArray *points = [NSMutableArray array]; 32 | CGPathApply(self.CGPath, (__bridge void *)points, getPointsFromBezier); 33 | return points; 34 | } 35 | @end 36 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 004---画板功能 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 004---画板服务器 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | // 7 | 8 | 9 | #import "ViewController.h" 10 | #import "UIBezierPath+point.h" 11 | #import "KCView.h" 12 | #import 13 | 14 | #define KCScreenWidth [UIScreen mainScreen].bounds.size.width 15 | #define KCScreenHeight [UIScreen mainScreen].bounds.size.height 16 | 17 | @interface ViewController () 18 | @property (nonatomic, strong) GCDAsyncUdpSocket *udpSocket; 19 | @property (weak, nonatomic) IBOutlet KCView *drawView; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | [self initWithDrawView]; 29 | } 30 | 31 | - (void)initWithDrawView{ 32 | 33 | __weak typeof(self) weakSelf = self; 34 | self.drawView.onePathEndBlock = ^(NSMutableDictionary *dict) { 35 | 36 | UIBezierPath *path = dict[@"drawPath"]; 37 | NSString *lineColor = dict[@"lineColor"]; 38 | CGFloat lineWidth = [dict[@"lineWidth"] floatValue]; 39 | 40 | NSArray *points = [path points]; 41 | NSMutableArray *temp = [NSMutableArray arrayWithCapacity:1]; 42 | for (id value in points) { 43 | CGPoint point = [value CGPointValue]; 44 | NSDictionary *dict = @{@"x":@(point.x),@"y":@(point.y)}; 45 | [temp addObject:dict]; 46 | } 47 | NSDictionary *passDic = @{@"points" : temp, 48 | @"lineWidth" : @(lineWidth), 49 | @"lineColor" : lineColor 50 | }; 51 | NSData *passData = [NSJSONSerialization dataWithJSONObject:passDic 52 | options:NSJSONWritingPrettyPrinted 53 | error:nil]; 54 | [weakSelf.udpSocket sendData:passData toHost:@"127.0.0.1" port:8070 withTimeout:-1 tag:10088]; 55 | }; 56 | } 57 | 58 | 59 | #pragma mark - 断开连接 60 | - (IBAction)didClickDisconnectAction:(id)sender { 61 | 62 | [self.drawView.pathArray removeAllObjects]; 63 | [self.drawView.currentPath removeAllPoints]; 64 | [self.drawView setNeedsDisplay]; 65 | } 66 | #pragma mark - 创建socket 67 | - (IBAction)didClickCreatSocketAction:(id)sender { 68 | // 1 创建socket 69 | if (!self.udpSocket) { 70 | self.udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(0, 0)]; 71 | } 72 | NSLog(@"创建socket 成功"); 73 | // 2: 绑定socket 74 | NSError * error = nil; 75 | [self.udpSocket bindToPort:8060 error:&error]; 76 | if (error) { 77 | //监听错误打印错误信息 78 | NSLog(@"error:%@",error); 79 | }else { 80 | // 3: 监听成功则开始接收信息 81 | [self.udpSocket beginReceiving:&error]; 82 | } 83 | } 84 | 85 | #pragma mark - GCDAsyncUdpSocketDelegate 86 | 87 | // 连接成功 88 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address{ 89 | NSLog(@"连接成功 --- %@",address); 90 | } 91 | 92 | // 连接失败 93 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotConnect:(NSError *)error{ 94 | NSLog(@"连接失败 反馈: %@",error); 95 | } 96 | 97 | // 发送数据成功 98 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag{ 99 | 100 | NSLog(@"%ld tag 发送数据成功",tag); 101 | } 102 | 103 | // 发送数据失败 104 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error{ 105 | NSLog(@"%ld tag 发送数据失败 : %@",tag,error); 106 | 107 | 108 | } 109 | 110 | // 接受数据的回调 111 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext{ 112 | 113 | NSDictionary *tempDic = [NSJSONSerialization JSONObjectWithData:data 114 | options:kNilOptions 115 | error:nil]; 116 | NSArray *pointArray = [tempDic objectForKey:@"points"]; 117 | UIBezierPath *tempPath = [UIBezierPath bezierPath]; 118 | for (int i = 0; i < pointArray.count; i++) { 119 | NSDictionary *pointDict = pointArray[i]; 120 | CGPoint point = CGPointMake([pointDict[@"x"] floatValue] , [pointDict[@"y"] floatValue]); 121 | if (i == 0) { 122 | //起始点 123 | [tempPath moveToPoint:point]; 124 | }else{ 125 | [tempPath addLineToPoint:point]; 126 | } 127 | } 128 | 129 | dispatch_async(dispatch_get_main_queue(), ^{ 130 | 131 | UIBezierPath *path = tempPath; 132 | NSString *lineColor = [tempDic objectForKey:@"lineColor"]; 133 | CGFloat lineWidth = [[tempDic objectForKey:@"lineWidth"] floatValue]; 134 | 135 | [self.drawView dealwithData:path lineColor:lineColor lineWidth:lineWidth]; 136 | [self.drawView setNeedsDisplay]; 137 | }); 138 | 139 | } 140 | 141 | // 关闭失败 142 | - (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error{ 143 | NSLog(@"关闭失败: %@",error); 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/004---画板功能/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 004---画板功能 4 | // 5 | // Created by Cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: a57856cab13b8b96af67d54cb31d3b6cad697f55 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板功能/Pods/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/CocoaAsyncSocket/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This library is in the public domain. 2 | However, not all organizations are allowed to use such a license. 3 | For example, Germany doesn't recognize the Public Domain and one is not allowed to use libraries under such license (or similar). 4 | 5 | Thus, the library is now dual licensed, 6 | and one is allowed to choose which license they would like to use. 7 | 8 | ################################################## 9 | License Option #1 : 10 | ################################################## 11 | 12 | Public Domain 13 | 14 | ################################################## 15 | License Option #2 : 16 | ################################################## 17 | 18 | Software License Agreement (BSD License) 19 | 20 | Copyright (c) 2017, Deusty, LLC 21 | All rights reserved. 22 | 23 | Redistribution and use of this software in source and binary forms, 24 | with or without modification, are permitted provided that the following conditions are met: 25 | 26 | * Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | 30 | * Neither the name of Deusty LLC nor the names of its 31 | contributors may be used to endorse or promote products 32 | derived from this software without specific prior 33 | written permission of Deusty LLC. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: a57856cab13b8b96af67d54cb31d3b6cad697f55 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaAsyncSocket : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaAsyncSocket 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaAsyncSocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 4 | OTHER_LDFLAGS = -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/Pods-004---画板功能/Pods-004---画板功能-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## CocoaAsyncSocket 5 | 6 | Public Domain License 7 | 8 | The CocoaAsyncSocket project is in the public domain. 9 | 10 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 11 | Updated and maintained by Deusty LLC and the Apple development community. 12 | 13 | Generated by CocoaPods - https://cocoapods.org 14 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/Pods-004---画板功能/Pods-004---画板功能-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Public Domain License 18 | 19 | The CocoaAsyncSocket project is in the public domain. 20 | 21 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 22 | Updated and maintained by Deusty LLC and the Apple development community. 23 | 24 | License 25 | public domain 26 | Title 27 | CocoaAsyncSocket 28 | Type 29 | PSGroupSpecifier 30 | 31 | 32 | FooterText 33 | Generated by CocoaPods - https://cocoapods.org 34 | Title 35 | 36 | Type 37 | PSGroupSpecifier 38 | 39 | 40 | StringsTable 41 | Acknowledgements 42 | Title 43 | Acknowledgements 44 | 45 | 46 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/Pods-004---画板功能/Pods-004---画板功能-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_004_______ : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_004_______ 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/Pods-004---画板功能/Pods-004---画板功能.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/Pods/Target Support Files/Pods-004---画板功能/Pods-004---画板功能.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板功能/podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target '004---画板功能' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | # use_frameworks! 7 | pod 'CocoaAsyncSocket', '~> 7.6.3' 8 | 9 | # Pods for 004---画板功能 10 | 11 | end 12 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板服务器/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板服务器/004---画板服务器/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | 7 | #import 8 | 9 | @interface AppDelegate : UIResponder 10 | 11 | @property (strong, nonatomic) UIWindow *window; 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | // Override point for customization after application launch. 19 | return YES; 20 | } 21 | 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 26 | } 27 | 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application { 41 | // 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. 42 | } 43 | 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/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 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/KCView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KCView.h 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | typedef void(^OnePathEndBlock)(NSMutableDictionary *dict); 11 | 12 | @interface KCView : UIView 13 | 14 | //当前正在绘制的贝塞尔曲线 15 | @property (strong, nonatomic) UIBezierPath *currentPath; 16 | // 总的贝塞尔曲线合集 17 | @property (strong, nonatomic) NSMutableArray *pathArray; 18 | // 贝塞尔曲线线条颜色 HEX 19 | @property (copy, nonatomic) NSString *lineColor; 20 | // 贝塞尔曲线线条宽度 21 | @property (assign, nonatomic) CGFloat lineWidth; 22 | //一条贝塞尔曲线绘制完成后的回调Block 23 | @property (copy, nonatomic) OnePathEndBlock onePathEndBlock; 24 | 25 | - (void)dealwithData:(UIBezierPath *)path lineColor:(NSString *)lineColor lineWidth:(CGFloat)lineWidth; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/KCView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KCView.m 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import "KCView.h" 9 | 10 | @implementation KCView 11 | 12 | #pragma mark -- init Method 13 | 14 | - (instancetype)initWithFrame:(CGRect)frame 15 | { 16 | self = [super initWithFrame:frame]; 17 | if (self) { 18 | [self setup]; 19 | } 20 | return self; 21 | } 22 | 23 | - (void)awakeFromNib{ 24 | [super awakeFromNib]; 25 | [self setup]; 26 | } 27 | 28 | 29 | - (void)setup{ 30 | 31 | _lineColor = @"0x000000"; 32 | _lineWidth = 5; 33 | } 34 | 35 | #pragma mark - drawRect 36 | 37 | - (void)drawRect:(CGRect)rect { 38 | 39 | if (self.pathArray.count) { 40 | for (NSMutableDictionary *dict in self.pathArray) { 41 | UIBezierPath *path = dict[@"drawPath"]; 42 | NSString *lineColor = dict[@"lineColor"]; 43 | CGFloat lineWidth = [dict[@"lineWidth"] floatValue]; 44 | [[self colorWithHexString:lineColor] set]; 45 | path.lineWidth = lineWidth; 46 | [path stroke]; 47 | } 48 | } 49 | } 50 | 51 | #pragma mark -- UIView Touch Action 52 | 53 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 54 | //获取起始坐标 55 | CGPoint startPoint = [self getCurrentPointWithTouches:[event allTouches]]; 56 | //初始化 57 | UIBezierPath *tempPath = [UIBezierPath bezierPath]; 58 | //绘制第一个点 59 | [tempPath moveToPoint:startPoint]; 60 | //设置线条风格 61 | tempPath.lineCapStyle = kCGLineCapRound; 62 | //设置连接处效果 63 | tempPath.lineJoinStyle = kCGLineJoinRound; 64 | tempPath.lineWidth = _lineWidth; 65 | _currentPath = tempPath; 66 | 67 | [self dealwithData:tempPath lineColor:_lineColor lineWidth:_lineWidth]; 68 | } 69 | 70 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 71 | //获取坐标 72 | CGPoint movePoint = [self getCurrentPointWithTouches:[event allTouches]]; 73 | //填充图形 74 | [_currentPath addLineToPoint:movePoint]; 75 | [self setNeedsDisplay]; 76 | } 77 | 78 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 79 | //一条线完成之后回调 80 | if (self.onePathEndBlock) { 81 | self.onePathEndBlock([self.pathArray lastObject]); 82 | } 83 | } 84 | 85 | - (CGPoint)getCurrentPointWithTouches:(NSSet *)touches{ 86 | //视图中的所有对象 87 | UITouch *touch = [touches anyObject]; 88 | //返回触摸点在视图中的坐标 89 | return [touch locationInView:touch.view]; 90 | } 91 | 92 | #pragma mark - 数据处理 93 | 94 | - (void)dealwithData:(UIBezierPath *)path lineColor:(NSString *)lineColor lineWidth:(CGFloat)lineWidth{ 95 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1]; 96 | [dict setValue:lineColor forKey:@"lineColor"]; 97 | [dict setValue:path forKey:@"drawPath"]; 98 | [dict setValue:@(lineWidth) forKey:@"lineWidth"]; 99 | [self.pathArray addObject:dict]; 100 | } 101 | 102 | 103 | #pragma mark -- Getter And Setter 104 | 105 | - (void)setLineColor:(NSString *)lineColor{ 106 | _lineColor = lineColor; 107 | } 108 | 109 | - (void)setLineWidth:(CGFloat)lineWidth{ 110 | _lineWidth = lineWidth; 111 | } 112 | 113 | - (NSMutableArray *)pathArray{ 114 | if (!_pathArray) { 115 | _pathArray = [NSMutableArray arrayWithCapacity:0]; 116 | } 117 | return _pathArray; 118 | } 119 | 120 | 121 | - (UIColor *) colorWithHexString: (NSString *) hexString 122 | { 123 | NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; 124 | CGFloat alpha, red, blue, green; 125 | switch ([colorString length]) { 126 | case 3: // #RGB 127 | alpha = 1.0f; 128 | red = [self colorComponentFrom: colorString start: 0 length: 1]; 129 | green = [self colorComponentFrom: colorString start: 1 length: 1]; 130 | blue = [self colorComponentFrom: colorString start: 2 length: 1]; 131 | break; 132 | case 4: // #ARGB 133 | alpha = [self colorComponentFrom: colorString start: 0 length: 1]; 134 | red = [self colorComponentFrom: colorString start: 1 length: 1]; 135 | green = [self colorComponentFrom: colorString start: 2 length: 1]; 136 | blue = [self colorComponentFrom: colorString start: 3 length: 1]; 137 | break; 138 | case 6: // #RRGGBB 139 | alpha = 1.0f; 140 | red = [self colorComponentFrom: colorString start: 0 length: 2]; 141 | green = [self colorComponentFrom: colorString start: 2 length: 2]; 142 | blue = [self colorComponentFrom: colorString start: 4 length: 2]; 143 | break; 144 | case 8: // #AARRGGBB 145 | alpha = [self colorComponentFrom: colorString start: 0 length: 2]; 146 | red = [self colorComponentFrom: colorString start: 2 length: 2]; 147 | green = [self colorComponentFrom: colorString start: 4 length: 2]; 148 | blue = [self colorComponentFrom: colorString start: 6 length: 2]; 149 | break; 150 | default: 151 | blue=0; 152 | green=0; 153 | red=0; 154 | alpha=0; 155 | break; 156 | } 157 | return [UIColor colorWithRed: red green: green blue: blue alpha: 1]; 158 | } 159 | 160 | - (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length 161 | { 162 | NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; 163 | NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; 164 | unsigned hexComponent; 165 | [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; 166 | return hexComponent ; 167 | } 168 | 169 | @end 170 | 171 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/UIBezierPath+point.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UIBezierPath (point) 5 | /*! 6 | @method  获得UIBezierPath曲线上的所有点坐标 7 | @abstract 获得UIBezierPath曲线上的所有点坐标 8 | @result 坐标点数组 9 | */ 10 | - (NSArray *)points; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/UIBezierPath+point.m: -------------------------------------------------------------------------------- 1 | #import "UIBezierPath+point.h" 2 | 3 | @implementation UIBezierPath (point) 4 | 5 | #define VALUE(_INDEX_) [NSValue valueWithCGPoint:points[_INDEX_]] 6 | 7 | void getPointsFromBezier(void *info,const CGPathElement *element){ 8 | 9 | NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info; 10 | CGPathElementType type = element->type; 11 | CGPoint *points = element->points; 12 | 13 | if (type != kCGPathElementCloseSubpath) { 14 | [bezierPoints addObject:VALUE(0)]; 15 | if ((type != kCGPathElementAddLineToPoint) && (type != kCGPathElementMoveToPoint)) { 16 | [bezierPoints addObject:VALUE(1)]; 17 | } 18 | } 19 | 20 | if (type == kCGPathElementAddCurveToPoint) { 21 | [bezierPoints addObject:VALUE(2)]; 22 | } 23 | 24 | } 25 | /*! 26 | @method  获得UIBezierPath曲线上的所有点坐标 27 | @abstract 获得UIBezierPath曲线上的所有点坐标 28 | @result 坐标点数组 29 | */ 30 | - (NSArray *)points 31 | { 32 | NSMutableArray *points = [NSMutableArray array]; 33 | CGPathApply(self.CGPath, (__bridge void *)points, getPointsFromBezier); 34 | return points; 35 | } 36 | @end 37 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | 10 | @interface ViewController : UIViewController 11 | 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | 9 | #import "ViewController.h" 10 | #import "UIBezierPath+point.h" 11 | #import "KCView.h" 12 | #import 13 | 14 | #define KCScreenWidth [UIScreen mainScreen].bounds.size.width 15 | #define KCScreenHeight [UIScreen mainScreen].bounds.size.height 16 | 17 | @interface ViewController () 18 | @property (nonatomic, strong) GCDAsyncUdpSocket *udpSocket; 19 | @property (weak, nonatomic) IBOutlet KCView *drawView; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | [self initWithDrawView]; 29 | } 30 | 31 | - (void)initWithDrawView{ 32 | 33 | __weak typeof(self) weakSelf = self; 34 | self.drawView.onePathEndBlock = ^(NSMutableDictionary *dict) { 35 | 36 | UIBezierPath *path = dict[@"drawPath"]; 37 | NSString *lineColor = dict[@"lineColor"]; 38 | CGFloat lineWidth = [dict[@"lineWidth"] floatValue]; 39 | 40 | NSArray *points = [path points]; 41 | NSMutableArray *temp = [NSMutableArray arrayWithCapacity:1]; 42 | for (id value in points) { 43 | CGPoint point = [value CGPointValue]; 44 | NSDictionary *dict = @{@"x":@(point.x),@"y":@(point.y)}; 45 | [temp addObject:dict]; 46 | } 47 | NSDictionary *passDic = @{@"points" : temp, 48 | @"lineWidth" : @(lineWidth), 49 | @"lineColor" : lineColor 50 | }; 51 | NSData *passData = [NSJSONSerialization dataWithJSONObject:passDic 52 | options:NSJSONWritingPrettyPrinted 53 | error:nil]; 54 | [weakSelf.udpSocket sendData:passData toHost:@"127.0.0.1" port:8070 withTimeout:-1 tag:10086]; 55 | }; 56 | } 57 | 58 | 59 | #pragma mark - 断开连接 60 | - (IBAction)didClickDisconnectAction:(id)sender { 61 | 62 | [self.drawView.pathArray removeAllObjects]; 63 | [self.drawView.currentPath removeAllPoints]; 64 | [self.drawView setNeedsDisplay]; 65 | } 66 | #pragma mark - 创建socket 67 | - (IBAction)didClickCreatSocketAction:(id)sender { 68 | 69 | // 1 创建socket 70 | if (!self.udpSocket) { 71 | self.udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(0, 0)]; 72 | } 73 | NSLog(@"创建socket 成功"); 74 | // 2: 绑定socket 75 | NSError * error = nil; 76 | [self.udpSocket bindToPort:8070 error:&error]; 77 | if (error) { 78 | //监听错误打印错误信息 79 | NSLog(@"error:%@",error); 80 | }else { 81 | // 3: 监听成功则开始接收信息 82 | [self.udpSocket beginReceiving:&error]; 83 | } 84 | 85 | } 86 | 87 | #pragma mark - GCDAsyncUdpSocketDelegate 88 | 89 | // 连接成功 90 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address{ 91 | NSLog(@"连接成功 --- %@",address); 92 | } 93 | 94 | // 连接失败 95 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotConnect:(NSError *)error{ 96 | NSLog(@"连接失败 反馈: %@",error); 97 | } 98 | 99 | // 发送数据成功 100 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag{ 101 | 102 | NSLog(@"%ld tag 发送数据成功",tag); 103 | } 104 | 105 | // 发送数据失败 106 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error{ 107 | NSLog(@"%ld tag 发送数据失败 : %@",tag,error); 108 | } 109 | 110 | // 接受数据的回调 111 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext{ 112 | 113 | NSDictionary *tempDic = [NSJSONSerialization JSONObjectWithData:data 114 | options:kNilOptions 115 | error:nil]; 116 | NSArray *pointArray = [tempDic objectForKey:@"points"]; 117 | UIBezierPath *tempPath = [UIBezierPath bezierPath]; 118 | for (int i = 0; i < pointArray.count; i++) { 119 | NSDictionary *pointDict = pointArray[i]; 120 | CGPoint point = CGPointMake([pointDict[@"x"] floatValue] , [pointDict[@"y"] floatValue]); 121 | if (i == 0) { 122 | //起始点 123 | [tempPath moveToPoint:point]; 124 | }else{ 125 | [tempPath addLineToPoint:point]; 126 | } 127 | } 128 | 129 | dispatch_async(dispatch_get_main_queue(), ^{ 130 | 131 | UIBezierPath *path = tempPath; 132 | NSString *lineColor = [tempDic objectForKey:@"lineColor"]; 133 | CGFloat lineWidth = [[tempDic objectForKey:@"lineWidth"] floatValue]; 134 | 135 | [self.drawView dealwithData:path lineColor:lineColor lineWidth:lineWidth]; 136 | [self.drawView setNeedsDisplay]; 137 | }); 138 | 139 | } 140 | 141 | // 关闭失败 142 | - (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error{ 143 | NSLog(@"关闭失败: %@",error); 144 | } 145 | 146 | 147 | 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/004---画板服务器/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 004---画板服务器 4 | // 5 | // Created by cooci on 2021/10/10. 6 | // 7 | 8 | #import 9 | #import "AppDelegate.h" 10 | 11 | int main(int argc, char * argv[]) { 12 | @autoreleasepool { 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: f5a807c0a071b8d66c6bca46f3c63161e972c620 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板服务器/Pods/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/CocoaAsyncSocket/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This library is in the public domain. 2 | However, not all organizations are allowed to use such a license. 3 | For example, Germany doesn't recognize the Public Domain and one is not allowed to use libraries under such license (or similar). 4 | 5 | Thus, the library is now dual licensed, 6 | and one is allowed to choose which license they would like to use. 7 | 8 | ################################################## 9 | License Option #1 : 10 | ################################################## 11 | 12 | Public Domain 13 | 14 | ################################################## 15 | License Option #2 : 16 | ################################################## 17 | 18 | Software License Agreement (BSD License) 19 | 20 | Copyright (c) 2017, Deusty, LLC 21 | All rights reserved. 22 | 23 | Redistribution and use of this software in source and binary forms, 24 | with or without modification, are permitted provided that the following conditions are met: 25 | 26 | * Redistributions of source code must retain the above 27 | copyright notice, this list of conditions and the 28 | following disclaimer. 29 | 30 | * Neither the name of Deusty LLC nor the names of its 31 | contributors may be used to endorse or promote products 32 | derived from this software without specific prior 33 | written permission of Deusty LLC. 34 | 35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Headers/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板服务器/Pods/Headers/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Headers/Private/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Headers/Public/CocoaAsyncSocket/GCDAsyncUdpSocket.h: -------------------------------------------------------------------------------- 1 | ../../../CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.h -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CocoaAsyncSocket (7.6.3) 3 | 4 | DEPENDENCIES: 5 | - CocoaAsyncSocket (~> 7.6.3) 6 | 7 | SPEC REPOS: 8 | https://github.com/CocoaPods/Specs.git: 9 | - CocoaAsyncSocket 10 | 11 | SPEC CHECKSUMS: 12 | CocoaAsyncSocket: eafaa68a7e0ec99ead0a7b35015e0bf25d2c8987 13 | 14 | PODFILE CHECKSUM: f5a807c0a071b8d66c6bca46f3c63161e972c620 15 | 16 | COCOAPODS: 1.5.0 17 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/.DS_Store -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_CocoaAsyncSocket : NSObject 3 | @end 4 | @implementation PodsDummy_CocoaAsyncSocket 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/CocoaAsyncSocket/CocoaAsyncSocket.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/CocoaAsyncSocket" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 4 | OTHER_LDFLAGS = -framework "CFNetwork" -framework "Security" 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/CocoaAsyncSocket 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/Pods-004---画板服务器/Pods-004---画板服务器-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## CocoaAsyncSocket 5 | 6 | Public Domain License 7 | 8 | The CocoaAsyncSocket project is in the public domain. 9 | 10 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 11 | Updated and maintained by Deusty LLC and the Apple development community. 12 | 13 | Generated by CocoaPods - https://cocoapods.org 14 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/Pods-004---画板服务器/Pods-004---画板服务器-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Public Domain License 18 | 19 | The CocoaAsyncSocket project is in the public domain. 20 | 21 | The original TCP version (AsyncSocket) was created by Dustin Voss in January 2003. 22 | Updated and maintained by Deusty LLC and the Apple development community. 23 | 24 | License 25 | public domain 26 | Title 27 | CocoaAsyncSocket 28 | Type 29 | PSGroupSpecifier 30 | 31 | 32 | FooterText 33 | Generated by CocoaPods - https://cocoapods.org 34 | Title 35 | 36 | Type 37 | PSGroupSpecifier 38 | 39 | 40 | StringsTable 41 | Acknowledgements 42 | Title 43 | Acknowledgements 44 | 45 | 46 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/Pods-004---画板服务器/Pods-004---画板服务器-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_004________ : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_004________ 5 | @end 6 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/Pods-004---画板服务器/Pods-004---画板服务器.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/Pods/Target Support Files/Pods-004---画板服务器/Pods-004---画板服务器.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CocoaAsyncSocket" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/CocoaAsyncSocket" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"CocoaAsyncSocket" -framework "CFNetwork" -framework "Security" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /小专栏-socket篇章代码/004---画板服务器/podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target '004---画板服务器' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | # use_frameworks! 7 | pod 'CocoaAsyncSocket', '~> 7.6.3' 8 | 9 | # Pods for 004---画板服务器 10 | 11 | end 12 | -------------------------------------------------------------------------------- /资源文件/KC_iOS杂货铺封面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/资源文件/KC_iOS杂货铺封面.png -------------------------------------------------------------------------------- /资源文件/cooci_QRCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/资源文件/cooci_QRCode.png -------------------------------------------------------------------------------- /资源文件/isa流程图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LGCooci/KCiOSGrocery/b4a05c4c961424c68f86ccbfaba79b27df43cc87/资源文件/isa流程图.png --------------------------------------------------------------------------------