Repository: FantasticLBP/codesnippets Branch: master Commit: 722b87bddc52 Files: 108 Total size: 143.2 KB Directory structure: gitextract_sgu_vuiw/ ├── .gitignore ├── LICENSE ├── README.md ├── commitlint.config.js ├── filetemplete/ │ └── Custom/ │ ├── PowerCollectionViewCell.xctemplate/ │ │ ├── TemplateInfo.plist │ │ ├── UICollectionViewCellObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ └── ___FILEBASENAME___.m │ │ ├── UICollectionViewCellSwift/ │ │ │ └── ___FILEBASENAME___.swift │ │ ├── UICollectionViewCellXIBObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ ├── ___FILEBASENAME___.m │ │ │ └── ___FILEBASENAME___.xib │ │ └── UICollectionViewCellXIBSwift/ │ │ ├── ___FILEBASENAME___.swift │ │ └── ___FILEBASENAME___.xib │ ├── PowerDataModel.xctemplate/ │ │ ├── NSObjectObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ └── ___FILEBASENAME___.m │ │ └── TemplateInfo.plist │ ├── PowerSingleton.xctemplate/ │ │ ├── NSObjectObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ └── ___FILEBASENAME___.m │ │ └── TemplateInfo.plist │ ├── PowerTableViewCell.xctemplate/ │ │ ├── TemplateInfo.plist │ │ ├── UITableViewCellObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ └── ___FILEBASENAME___.m │ │ ├── UITableViewCellSwift/ │ │ │ └── ___FILEBASENAME___.swift │ │ ├── UITableViewCellXIBObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ ├── ___FILEBASENAME___.m │ │ │ └── ___FILEBASENAME___.xib │ │ └── UITableViewCellXIBSwift/ │ │ ├── ___FILEBASENAME___.swift │ │ └── ___FILEBASENAME___.xib │ ├── PowerView.xctemplate/ │ │ ├── TemplateInfo.plist │ │ ├── UIViewObjective-C/ │ │ │ ├── ___FILEBASENAME___.h │ │ │ └── ___FILEBASENAME___.m │ │ └── UIViewXIBObjective-C/ │ │ ├── ___FILEBASENAME___.h │ │ ├── ___FILEBASENAME___.m │ │ └── ___FILEBASENAME___.xib │ └── PowerViewController.xctemplate/ │ ├── TemplateInfo.plist │ ├── UIViewControllerObjective-C/ │ │ ├── ___FILEBASENAME___.h │ │ └── ___FILEBASENAME___.m │ └── UIViewControllerXIBObjective-C/ │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib ├── package.json ├── snippets/ │ ├── 03B5A35E-EB35-4CA6-BE35-A6CDADBF3E6D.codesnippet │ ├── 03E31638-8AF1-4DBE-B31B-13B60D7F41BD.codesnippet │ ├── 0694D07C-5801-4583-95A9-D0212ADFE2F0.codesnippet │ ├── 11301976-242F-4D49-BA35-74606642A8AB.codesnippet │ ├── 1C77FDE1-E281-415D-97F2-141962046C7A.codesnippet │ ├── 1DEE960F-DB0D-4266-A185-1A139ABD5DE9.codesnippet │ ├── 209CDA3A-77C5-4506-92FE-2E1BACB97C61.codesnippet │ ├── 275B6FBD-789B-45C5-A04F-8A0911B47677.codesnippet │ ├── 277AA03D-D9EF-4EF0-8368-0A0522615226.codesnippet │ ├── 2B2A78A6-3DB5-4D1C-8401-B0C4108F3544.codesnippet │ ├── 2B88F869-D37D-4451-90C6-83923D0942D6.codesnippet │ ├── 2D5BB815-5A58-4CD2-A636-572F3331B1B3.codesnippet │ ├── 2E2654CC-E49E-4F6C-BD26-6E4F0BCCC4CD.codesnippet │ ├── 33153DCC-8748-4AE2-8832-4EA2BCFA79E2.codesnippet │ ├── 371D1B02-BB6E-4601-AB18-6BEE7DF791D9.codesnippet │ ├── 37B6B32D-BE8C-4A6C-A426-A31715E36377.codesnippet │ ├── 3D903ED6-6B9E-481C-B56F-3DBC997647EA.codesnippet │ ├── 420DCB87-CF51-4430-AF4D-FABDFCBC990A.codesnippet │ ├── 4B823738-51F6-4577-B6F4-A3743C421954.codesnippet │ ├── 52A5D59C-7D4E-4E93-A0BB-D826B89BDBE4.codesnippet │ ├── 6521D6E4-60D5-4B65-8BB8-B6F9214786E4.codesnippet │ ├── 6E3D9C27-EADC-4169-8262-3EABCEF76F26.codesnippet │ ├── 704FA5E6-6F39-4B1D-AFCF-CC6A471BE8DA.codesnippet │ ├── 70B72C45-F1A5-4BC1-85F2-1315CB26B6E4.codesnippet │ ├── 745A7446-3A07-4214-87A0-539DD6464A37.codesnippet │ ├── 74B99378-1AD3-45A4-85E5-AA0AD8CBEF57.codesnippet │ ├── 7502B441-E8B3-46DE-A0E9-310689F3E281.codesnippet │ ├── 788CE23F-0ED2-4D3A-8F0B-29C9857EC5E9.codesnippet │ ├── 8A98B142-2FDB-465E-A80B-C91A1F1910AB.codesnippet │ ├── 8AE1227B-6823-4CD8-9705-F52BF113CE8F.codesnippet │ ├── 8D5EFC11-0FFE-4180-8127-FF3ACC9B5705.codesnippet │ ├── 928529DE-46F1-4522-90D2-2743665C1A2C.codesnippet │ ├── A3D9F9B6-3C1D-441A-99AF-49F3CD9A00D7.codesnippet │ ├── A6510304-574A-4A4E-BAED-577B1B314377.codesnippet │ ├── A6D7B6F4-4E4F-486C-A8B8-7E068F5631FB.codesnippet │ ├── A7135568-6312-4234-9838-DF2086CBBA4A.codesnippet │ ├── A79C2ADB-2177-48C0-B2A6-449A6928EA7D.codesnippet │ ├── A92834F3-256A-4508-9CC2-57B242780B4A.codesnippet │ ├── AE16B32F-55B1-4757-AE9C-F392F1115EEB.codesnippet │ ├── B21D4EF7-1AFB-4F78-B6E4-4180475A3EE5.codesnippet │ ├── B3F0923F-776E-4B13-95BB-2D80B4D771AA.codesnippet │ ├── B4802492-A5F7-475B-A80B-1A414A7EB42A.codesnippet │ ├── BCBFB1D9-5EDD-4F8A-87A7-B087307C1CA6.codesnippet │ ├── BF9C74C4-D9CC-442C-9343-C9295D448CAF.codesnippet │ ├── C1C29A6B-AADD-4D4B-9608-2BB78D6CB38A.codesnippet │ ├── C21AA954-1018-41C7-A9C4-CF0F0481B64F.codesnippet │ ├── C25DBAAC-E555-4159-840B-6CABA292EE03.codesnippet │ ├── C3821029-7680-4D9E-8247-857D54278DB3.codesnippet │ ├── C7FF27C0-7E66-4A29-80D4-1285A89F93AF.codesnippet │ ├── D7227C17-6368-4FA9-BCD1-D354BC129AD9.codesnippet │ ├── E6B15072-CD4B-4DE5-BE9D-6306DB609A32.codesnippet │ ├── E87096D8-7617-467F-A3AB-742D7E36ED55.codesnippet │ ├── E8E74582-3E40-43F4-82E4-273EBC57372F.codesnippet │ ├── E935C1C4-D472-4D34-B5AD-86D20EBC61BC.codesnippet │ ├── F07D17AE-4941-475F-BB33-4F9F27CC69F3.codesnippet │ ├── F20FD025-017A-4B29-B450-71A1C4CAB992.codesnippet │ ├── F7811228-EC34-4A6E-A926-558A637782E1.codesnippet │ ├── F856017E-E797-4E46-9B9D-BC6F2E454808.codesnippet │ ├── FC9F0763-DC79-4E21-B15A-092C04DB2C40.codesnippet │ ├── FD779057-D489-4726-BA41-C3715D7D697F.codesnippet │ ├── FDAC1BE2-9CED-4A84-A821-BD8BCA8428C5.codesnippet │ ├── FEDC91B5-80F6-4C66-AF76-67871903EE51.codesnippet │ ├── FF4BEF07-88F0-49F8-A3AA-33A90F2F6411.codesnippet │ ├── headerdoc.codesnippet │ └── singleton.codesnippet ├── syncSnippets.sh └── uploadMySnippets.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ node_modules/ ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ > 软件的生命周期贯穿产品的开发,测试,生产,用户使用,版本升级和后期维护等过程,只有易读,易维护的软件代码才具有生命力。 ## 一、思路 最近重构项目组件,看到项目中存在一些命名和方法分块方面存在一些问题,结合平时经验和 [Apple官方代码规范](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html) 在此整理出 iOS 工程规范。提出第一个版本,如果后期觉得有不完善的地方,继续提出来不断完善,文档在此记录的目的就是为了大家的代码可读性较好,后来的人或者团队里面的其他人看到代码可以不会因为代码风格和可读性上面造成较大时间的开销。 先梳理出规范,然后使用一些脚本的方式,提高大家使用的便捷性与效率,最后开发一些协作脚本。 ## 二、一些原则 1. 长的,描述性的方法和变量命名是好的。不要使用简写,除非是一些大家都知道的场景比如 VIP。不要使用 bgView,推荐使用 backgroundView 2. 见名知意。含义清楚,做好不加注释代码自我表述能力强。(前提是代码足够规范) 3. 不要过分追求技巧,降低代码可读性 4. 删除没必要的代码。比如我们新建一个控制器,里面会有一些不会用到的代码,或者注释起来的代码,如果这些代码不需要,那就删除它,留着偷懒吗?下次需要自己手写 5. 在方法内部不要重复计算某个值,适当的情况下可以将计算结果缓存起来 6. 尽量减少单例的使用。 7. 提供一个统一的数据管理入口,不管是 MVC、MVVM、MVP 模块内提供一个统一的数据管理入口会使得代码变得更容易管理和维护。 8. 除了 .m 文件中方法,其他的地方"{"不需要另起一行。 ```Objective-c - (void)getGooodsList { ... } - (void)doHomework { if (self.hungry) { return; } if (self.thirsty) { return; } if (self.tired) { return; } papapa.then.over; } ``` ### 变量 1. 一个变量最好只有一个作用,切勿为了节省代码行数,觉得一个变量可以做多个用途。(单一原则) 2. 方法内部如果有局部变量,那么局部变量应该靠近在使用的地方,而不是全部在顶部声明全部的局部变量。 ### 运算符 1. 1元运算符和变量之间不需要空格。例如:++n 2. 2元运算符与变量之间需要空格隔开。例如: containerWidth = 0.3 * Screen_Width 3. 当有多个运算符的时候需要使用括号来明确正确的顺序,可读性较好。例如: 2 << (1 + 2 * 3 - 4) ### 条件表达式 1. 当有条件过多、过长的时候需要换行,为了代码看起来整齐些 ``` //good if (condition1() && condition2() && condition3() && condition4()) { // Do something } //bad if (condition1() && condition2() && condition3() && condition4()) { // Do something } ``` 2. 在一个代码块里面有个可能的情况时善于使用 `return` 来结束异常的情况。 ``` - (void)doHomework { if (self.hungry) { return; } if (self.thirsty) { return; } if (self.tired) { return; } papapa.then.over; } ``` 3. 每个分支的实现都必须使用 {} 包含。 ``` // bad if (self.hungry) self.eat() // good if (self.hungry) { self.eat() } ``` 4. 条件判断的时候应该是变量在左,条件在右。 if ( currentCursor == 2 ) { //... } 5. switch 语句后面的每个分支都需要用大括号括起来。 6. switch 语句后面的 default 分支必须存在,除非是在对枚举进行 switch。 ``` switch (menuType) { case menuTypeLeft: { ... break; } case menuTypeRight: { ... break; } case menuTypeTop: { ... break; } case menuTypeBottom: { ... break; } } ``` ### 类名 1. 大写驼峰式命名。每个单词首字母大写。比如「申请记录控制器」ApplyRecordsViewController 2. 每个类型的命名以该类型结尾。 - ViewController:使用 `ViewController` 结尾。例子:ApplyRecordsViewController - View:使用 `View` 结尾。例子:分界线:boundaryView - NSArray:使用 `s` 结尾。比如商品分类数据源。categories - UITableViewCell:使用 `Cell` 结尾。比如 MyProfileCell - Protocol:使用 `Delegate` 或者 `Datasource` 结尾。比如 XQScanViewDelegate - Tool:工具类 - 代理类:Delegate - Service 类:Service ### 类的注释 有时候我们需要为我们创建的类设置一些注释。我们可以在类的下面添加。 ### 枚举 枚举的命名和类的命名相近。 ``` typedef NS_ENUM(NSInteger, UIControlContentVerticalAlignment) { UIControlContentVerticalAlignmentCenter = 0, UIControlContentVerticalAlignmentTop = 1, UIControlContentVerticalAlignmentBottom = 2, UIControlContentVerticalAlignmentFill = 3, }; ``` ### 宏 1. 全部大写,单词与单词之间用 `_` 连接。 2. 以 `K` 开头。后面遵循大写驼峰命名。「不带参数」 ``` #define HOME_PAGE_DID_SCROLL @"com.xq.home.page.tableview.did.scroll" #define KHomePageDidScroll @"com.xq.home.page.tableview.did.scroll" ``` ### 属性 书写规则,基本上就是 `@property 之后空一格,括号,里面的 线程修饰词、内存修饰词、读写修饰词,空一格 类 对象名称` 根据不同的场景选择合适的修饰符。 ``` @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, assign, readonly) BOOL loading; @property (nonatomic, weak) id<#delegate#> delegate; @property (nonatomic, copy) <#returnType#> (^<#Block#>)(<#parType#>); ``` ### 单例 单例适合全局管理状态或者事件的场景。一旦创建,对象的指针保存在静态区,单例对象在堆内存中分配的内存空间只有程序销毁的时候才会释放。基于这种特点,那么我们类似 UIApplication 对象,需要全局访问唯一一个对象的情况才适合单例,或者访问频次较高的情况。我们的功能模块的生命周期肯定小于 App 的生命周期,如果多个单例对象的话,势必 App 的开销会很大,糟糕的情况系统会杀死 App。如果觉得非要用单例比较好,那么注意需要在合适的场合 tearDown 掉。 单例的使用场景概括如下: - 控制资源的使用,通过线程同步来控制资源的并发访问。 - 控制实例的产生,以达到节约资源的目的。 - 控制数据的共享,在不建立直接关联的条件下,让多个不相关的进程或线程之间实现通信。 ```objective-c + (instancetype)sharedInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ //because has rewrited allocWithZone use NULL avoid endless loop lol. _sharedInstance = [[super allocWithZone:NULL] init]; }); return _sharedInstance; } + (id)allocWithZone:(struct _NSZone *)zone { return [TestNSObject sharedInstance]; } + (instancetype)alloc { return [TestNSObject sharedInstance]; } - (id)copy { return self; } - (id)mutableCopy { return self; } - (id)copyWithZone:(struct _NSZone *)zone { return self; } ``` ### 私有变量 推荐以 `_` 开头,写在 .m 文件中。例如 NSString * _somePrivateVariable ### 代理方法 1. 类的实例必须作为方法的参数之一。 2. 对于一些连续的状态的,可以加一些 will(将要)、did(已经) 3. 以类的名称开头 ```objective-c - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; ``` ### 方法 1. 方法与方法之间间隔一行 2. 大量的方法尽量要以组的形式放在一起,比如生命周期函数、公有方法、私有方法、setter && getter、代理方法.. 3. 方法最后面的括号需要另起一行。遵循 Apple 的规范 4. 对于其他场景的括号,括号不需要单独换行。比如 if 后面的括号。 5. 如果方法参数过多过长,建议多行书写。用冒号进行对齐。 6. 一个方法内的代码最好保持在50行以内,一般经验来看如果一个方法里面的代码行数过多,代码的阅读体验就很差(别问为什么,做过重构代码行数很长的人都有类似的心情) 7. 一个函数只做一个事情,做到单一原则。所有的类、方法设计好后就可以类似搭积木一样实现一个系统。 8. 对于有返回值的函数,且函数内有分支情况。确保每个分支都有返回值。 9. 函数如果有多个参数,外部传入的参数需要检验参数的非空、数据类型的合法性,参数错误做一些措施:立即返回、断言。 10. 多个函数如果有逻辑重复的代码,建议将重复的部分抽取出来,成为独立的函数进行调用 ```objective-c - (instancetype)init { self = [super init]; if (self) { <#statements#> } return self; } - (void)doHomework:(NSString *)name period:(NSInteger)second score:(NSInteger)score; ``` 11. 方法如果有多个参数的情况下需要注意是否需要介词和连词。很多时候在不知道如何抉择测时候思考下苹果的一些 API 的方法命名。 ```objective-c //good - (instancetype)initWithAge:(NSInteger)age name:(NSString *)name; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; //bad - (instancetype)initWithAge:(NSInteger)age andName:(NSString *)name; - (void)tableView:(UITableView *)tableView :(NSIndexPath *)indexPath; ``` 12. `.m` 文件中的私有方法需要在顶部进行声明 13. 方法组之间也有个顺序问题。 - 在文件最顶部实现属性的声明、私有方法的声明(很多人省去这一步,问题不大,但是蛮多第三方的库都写了,看起来还是会很方便,建议书写)。 - 在生命周期的方法里面,比如 viewDidLoad 里面只做界面的添加,而不是做界面的初始化,所有的 view 初始化建议放在 getter 里面去做。往往 view 的初始化的代码长度会比较长、且一般会有多个 view 所以 getter 和 setter 一般建议放在最下面,这样子顶部就可以很清楚的看到代码的主要逻辑。 - 所有button、gestureRecognizer 的响应事件都放在这个区域里面,不要到处乱放。 文件基本上就是 ```objective-c //___FILEHEADER___ #import "___FILEBASENAME___.h" /*ViewController*/ /*View&&Util*/ /*model*/ /*NetWork InterFace*/ /*Vender*/ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (void)viewWillAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = <#value#>; } - (void)viewWillDisappear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidAppear:animated]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - public Method #pragma mark - private method #pragma mark - event response #pragma mark - UITableViewDelegate #pragma mark - UITableViewDataSource //...(多个代理方法依次往下写) #pragma mark - getters and setters @end ``` ### 图片资源 1. 单个文件的命名 文件资源的命名也需要一定的规范,形式为:功能模块名_类别_功能_状态@nx.png Setting_Button_search_selected@2x.png、Setting_Button_search_selected@3x.png Setting_Button_search_unselected@2x.png、Setting_Button_search_unselected@3x.png 2. 资源的文件夹命名 最好也参考 App 按照功能模块建立对应的实体文件夹目录,最后到对应的目录下添加相应的资源文件。 ### 注释 1. 对于类的注释写在当前类文件的顶部 2. 对于属性的注释需要写在属性后面的地方。 //** 2.0.0 | | a.**B**.c | 属于小部分内容的更新 | 1.0.2 -> 1.1.1 | | a.b.**C** | 属于补丁更新 | 1.0.2 -> 1.0.3 | ### 改进 我们知道了平时在使用 Xcode 开发的过程中使用的系统提供的代码块所在的地址和新建控制器、模型、view等的文件模版的存放文件夹地址后,我们就可以设想下我们是否可以定制自己团队风格的控制器模版、是否可以打造和维护自己团队的高频使用的代码块? 答案是可以的。 Xcode 代码块的存放地址:`~/Library/Developer/Xcode/UserData/CodeSnippets` Xcode 文件模版的存放地址:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/ ### 意义 1. 为了个人或者团队开发者的代码更加规范。Property的书写的时候的空格、线程修饰词、内存修饰词的先后顺序 2. 提供大量可用的代码块,提高开发效率。比如在 Xcode 里面敲 UITableView_init 便可以自动懒加载创建一个 UITabelView 对象,你只需要设置在指定的位置写相应的参数 3. 通过一些代码块提高代码规范、避免一些bug。比如曾看到过 block 属性用 strong 修饰的代码,造成内存泄漏。举个例子你在 Xcode 中输入 **Property_delegate** 就会出来 `@property (nonatomic, weak) id<<#delegate#>> delegate;`,你输入 **Property_block** 就会出来 `@property (nonatomic, copy) <#returnType#> (^<#Block#>)(<#parType#>);` ## 三、 代码块的改造 我们可以将属性、控制器生命周期方法、单例构造一个对象的方法、代理方法、block、GCD、UITableView 懒加载、UITableViewCell 注册、UITableView 代理方法的实现、UICollectionVIew 懒加载、UICollectionVIewCell 注册、UICollectionView 的代理方法实现等等组织为 codesnippets ### 思考 - 封装好 codesnippets 之后团队除了你编写这个项目的人如何使用?如何知道是否有这个代码块? 方案:先在团队内召开代码规范会议,大家都统一知道这个事情在。之后大家共同维护 codesnippets。用法见下 属性:通过 **Property_类型** 开头,回车键自动补全。比如 Strong 类型,编写代码通过 Property_Strong 回车键自动补全成如下格式 ```objective-c @property (nonatomic, strong) <#Class#> *<#object#>; ``` 方法:以 **Method_关键词** 回车键确认,自动补全。比如 Method_UIScrollViewDelegate 回车键自动补全成 如下格式 ```objective-c #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { } ``` 各种常见的 Mark:以 **Mark_关键词** 回车确认,自动补全。比如 Method_MethodsGroup 回车键自动补全成 如下格式 ```objective-c #pragma mark - life cycle #pragma mark - public Method #pragma mark - private method #pragma mark - event response #pragma mark - UITableViewDelegate #pragma mark - UITableViewDataSource #pragma mark - getters and setters ``` - 封装好 codesnippets 之后团队内如何统一?想到一个方案,可以将团队内的 codesnippets 共享到 git,团队内的其他成员再从云端拉取同步。这样的话团队内的每个成员都可以使用最新的 codesnippets 来编码。 编写 shell 脚本。几个关键步骤: 1. 给系统文件夹授权 2. 在脚本所在文件夹新建存放代码块的文件夹 3. 将系统文件夹下面的代码块复制到步骤2创建的文件夹下面 4. 将当前的所有文件提交到 Git 仓库 ## 四、文件模版的改造 我们观察系统文件模版的特点,和在 Xcode 新建文件模版对应。 ![Xcode file template存放地址](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190304_filetemplates.png) 所以我们新建 Custom 文件夹,将系统 Source 文件夹下面的 Cocoa Touch Class.xctemplate 复制到 Custom 文件夹下。重命名为我们需要的名字,我这里以“Power”为例 ![自定义文件模版示例](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190319-filetemplateSelf.png) 进入 PowerViewController.xctemplate/PowerViewControllerObjective-C 修改 `___FILEBASENAME___.h` 和 `___FILEBASENAME___.m` 文件内容 ![注意点1](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190304-fileTmplates3.png) 在替换 .h 文件内容的时候后面改为 UIViewController,不然其他开发者新建文件模版的时候出现的不是 UIViewController 而是我们的 PowerViewController ![.m文件内容](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190304_filetemplates4.png) 修改 TemplateInfo.plist ![plist注意点](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190319-filetemplate5.png) 思考: - 如何使用 商量好一个标识(“Power”)。比如我新建了单例、控制器、Model、UIView、UITableViewCell、UICollectionViewCell6个模版,都以为 Power 开头。 ![模版用法](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/20190319-filetemplate6.png) - 如何共享 以 shell 脚本为工具。使用脚本将 git 云端的代码模版同步到本地 Xcode 文件夹对应的位置就可以使用了。关键步骤: 1. git clone 代码到脚本所在文件夹 2. 进入存放 codesnippets 的文件夹将内容复制到系统存放 codesnippets 的地方 3. 进入存放 file template 的文件夹将内容复制到系统存放 file template 的地方 ## 六、使用 ### 1. Xcode 中开发 - Property 属性。敲 **Property_** 自动联想,光标移动选中后敲回车自动补全 - Mark 标识。 敲 **Mark_** 自动联想,会展示各种常用的 Mark,光标移动选中后敲回车自动补全 - Method 方法。敲 **Method_** 自动联想,会展示各种常用的 Method,光标移动选中后敲回车自动补全 - GCD。敲 **GCD_** 自动联想,会展示各种常用的 GCD,光标移动选中后敲回车自动补全 - 常用 UI 控件的懒加载。敲 **_init** 自动联想,展示常用的 UI 控件的懒加载,光标移动选中后敲回车自动补全 - Delegate。敲 **Delegate_** 自动联想,会展示各种常用的 Delegate,光标移动选中后敲回车自动补全 - Notification。敲 **NSNotification_** 自动联想,会展示各种常用的 NSNotification 的代码块,比如发送通知、添加观察者、移除观察者、观察者方法的实现等等,光标移动选中后敲回车自动补全 - Protocol。敲 **Protocol_** 自动联想,会展示各种常用的 Protocol 的代码块,光标移动选中后敲回车自动补全 - 内存修饰代码块 - 工程常用 TODO、FIXME、Mark。敲 **Mark_** 自动联想,会展示各种常用的 Mark 的代码块,光标移动选中后敲回车自动补全 - 内存修饰代码块。敲 **Memory_** 自动联想,会展示各种常用的内存修饰的代码块,光标移动选中后敲回车自动补全 - 一些常用的代码块。敲 **Thread_** 等自动联想,选中后敲回车自动补全。 ### 2. Code Snippet 同步 你可能是代码块的创建者,也可能是使用方,使用的时候直接先给脚本赋权 ``` chmod +x ./syncSnippets.sh // 为脚本设置可执行权限 ./syncSnippets.sh // 同步git云端代码块和文件模版到本地 ``` 如果自己有新的代码块创建,觉得不错,想同步到远端 github repo,则可以使用下面的命令 ```shell chmod +x ./uploadMySnippets.sh // 为脚本设置可执行权限 ./uploadMySnippets.sh //将本地的代码块和文件模版同步到云端 ``` ![](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2021-1008-CodeSnippetMethodGroup.png) ![](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2021-1008-CodeSnippetProperty.png) ![](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2021-1008-CodeSnippetLazyLoad.png) ## PS **不断完善中。大家有好用或者不错的代码块或者文件模版希望参与到这个项目中来,为我们开发效率的提升添砖加瓦、贡献力量** 目前新建了大概58个代码段和6个类文件模版(UIViewController控制器带有方法组、模型、线程安全的单例模版、带有布局方法的UIView模版、UITableViewCell、UICollectionViewCell模版) shell 脚本基本有每个函数和关键步骤的代码注释,想学习 shell 的人可以看看代码。[代码传送门](https://github.com/FantasticLBP/codesnippets) ================================================ FILE: commitlint.config.js ================================================ const types = [ 'build', 'ci', 'chore', 'docs', 'feat', 'fix', 'pref', 'refactor', 'revert', 'style', 'test' ]; typeEnum = { rules: { 'type-enum': [2, 'always', types] }, value: () => types } module.exports = { extends: [ "@commitlint/config-conventional" ], rules: { 'type-case': [0], 'type-empty': [0], 'scope-empty': [0], 'scope-case': [0], 'subject-full-stop': [0, 'never'], 'subject-case': [0, 'never'], 'header-max-length': [0, 'always', 72], 'type-enum': typeEnum.rules['type-enum'] } }; ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default UICollectionViewCell FallbackHeader #import <UIKit/UIKit.h> Values UICollectionViewCell Suffixes UICollectionViewCell CollectionViewCell Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UICollectionViewCell Default false NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } #if DEBUG - (void)dealloc { NSLog(@"[%@ dealloc]", NSStringFromClass(self.class)); } #endif #pragma mark - Initial Methods - (void)commonInit { /*custom view u want draw in here*/ self.contentView.backgroundColor = [UIColor whiteColor]; } #pragma mark - Layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { [super layoutSubviews]; /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - private method #pragma mark - public method #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellSwift/___FILEBASENAME___.swift ================================================ //___FILEHEADER___ /* System */ import UIKit /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { //MARK: - public property //MARK: - readonly property //MARK: - getters and setters //MARK: - life cycle override init(frame: CGRect) { super.init(frame: frame) self.commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.commonInit() } //MARK: - layout override func updateConstraints() { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ super.updateConstraints() //this line must be the last line of this method.^_^ } override func layoutSubviews() { super.layoutSubviews() /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #if DEBUG deinit { print("[\(type(of: self)) deinit]") } #endif } //MARK: - initial Methods fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { func commonInit() { self.contentView.backgroundColor = UIColor.white; } } //MARK: - private method fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { } //MARK: - public method extension ___FILEBASENAMEASIDENTIFIER___ { } ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } #if DEBUG - (void)dealloc { NSLog(@"[%@ dealloc]", NSStringFromClass(self.class)); } #endif #pragma mark - Initial Methods - (void)commonInit { /*custom view u want draw in here*/ self.contentView.backgroundColor = [UIColor whiteColor]; } #pragma mark - Layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { [super layoutSubviews]; /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - private method #pragma mark - getters and setters #pragma mark - public method @end ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.xib ================================================ ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellXIBSwift/___FILEBASENAME___.swift ================================================ //___FILEHEADER___ /* System */ import UIKit /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { //MARK: - public property //MARK: - readonly property //MARK: - getters and setters //MARK: - life cycle override init(frame: CGRect) { super.init(frame: frame) self.commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.commonInit() } //MARK: - layout override func updateConstraints() { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ super.updateConstraints() //this line must be the last line of this method.^_^ } override func layoutSubviews() { super.layoutSubviews() /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #if DEBUG deinit { print("[\(type(of: self)) deinit]") } #endif } //MARK: - initial Methods fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { func commonInit() { self.contentView.backgroundColor = UIColor.white; } } //MARK: - private method fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { } //MARK: - public method extension ___FILEBASENAMEASIDENTIFIER___ { } ================================================ FILE: filetemplete/Custom/PowerCollectionViewCell.xctemplate/UICollectionViewCellXIBSwift/___FILEBASENAME___.xib ================================================ ================================================ FILE: filetemplete/Custom/PowerDataModel.xctemplate/NSObjectObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : NSObject @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerDataModel.xctemplate/NSObjectObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" #import @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; } - (NSString *)description { return [self yy_modelDescription]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - yymodel method /*自定义属性映射*/ //+ (NSDictionary *)modelCustomPropertyMapper { // //} /*自定义容器映射*/ //+ (NSDictionary *)modelContainerPropertyGenericClass { // //} // 当 JSON 转为 Model 完成后,该方法会被调用。 // 你可以在这里对数据进行校验,如果校验不通过,可以返回 NO,则该 Model 会被忽略。 // 你也可以在这里做一些自动转换不能完成的工作。 - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic { return YES; } // 当 Model 转为 JSON 完成后,该方法会被调用。 // 你可以在这里对数据进行校验,如果校验不通过,可以返回 NO,则该 Model 会被忽略。 // 你也可以在这里做一些自动转换不能完成的工作。 - (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic { return YES; } @end ================================================ FILE: filetemplete/Custom/PowerDataModel.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default NSObject FallbackHeader #import <UIKit/UIKit.h> Values NSObject Suffixes NSObject Model Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UIViewController Default false NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerSingleton.xctemplate/NSObjectObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : NSObject + (instancetype)sharedInstance; @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerSingleton.xctemplate/NSObjectObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ static ___FILEBASENAMEASIDENTIFIER___ *_sharedInstance = nil; #pragma mark - life cycle + (instancetype)sharedInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ //because has rewrited allocWithZone use NULL avoid endless loop lol. _sharedInstance = [[super allocWithZone:NULL] init]; }); return _sharedInstance; } + (id)allocWithZone:(struct _NSZone *)zone { return [___FILEBASENAMEASIDENTIFIER___ sharedInstance]; } + (instancetype)alloc { return [___FILEBASENAMEASIDENTIFIER___ sharedInstance]; } - (id)copy { return self; } - (id)mutableCopy { return self; } - (id)copyWithZone:(struct _NSZone *)zone { return self; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif @end ================================================ FILE: filetemplete/Custom/PowerSingleton.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default NSObject FallbackHeader #import <UIKit/UIKit.h> Values NSObject Suffixes NSObject NSObject Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UIViewController Default false NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default UITableViewCell FallbackHeader #import <UIKit/UIKit.h> Values UITableViewCell Suffixes UITableViewCell TableViewCell Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UITableViewCell Default false NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } #if DEBUG - (void)dealloc { NSLog(@"[%@ dealloc]", NSStringFromClass(self.class)); } #endif #pragma mark - initial Methods - (void)commonInit { /*custom view u want draw in here*/ self.contentView.backgroundColor = [UIColor whiteColor]; } #pragma mark - layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { [super layoutSubviews]; /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - private method #pragma mark - public method #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellSwift/___FILEBASENAME___.swift ================================================ //___FILEHEADER___ /* System */ import UIKit /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { //MARK: - public property //MARK: - readonly property //MARK: - getters and setters //MARK: - life cycle override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) self.commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.commonInit() } //MARK: - layout override func updateConstraints() { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ super.updateConstraints() //this line must be the last line of this method.^_^ } override func layoutSubviews() { super.layoutSubviews() /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #if DEBUG deinit { print("[\(type(of: self)) deinit]") } #endif } //MARK: - initial Methods fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { func commonInit() { self.contentView.backgroundColor = UIColor.white; } } //MARK: - private method fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { } //MARK: - public method extension ___FILEBASENAMEASIDENTIFIER___ { } ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /* System */ /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } #if DEBUG - (void)dealloc { NSLog(@"[%@ dealloc]", NSStringFromClass(self.class)); } #endif #pragma mark - initial Methods - (void)commonInit { /*custom view u want draw in here*/ self.contentView.backgroundColor = [UIColor whiteColor]; } #pragma mark - layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { [super layoutSubviews]; /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - private method #pragma mark - public method #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.xib ================================================ ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellXIBSwift/___FILEBASENAME___.swift ================================================ //___FILEHEADER___ /* System */ import UIKit /* ViewController */ /* View */ /* Model */ /* Util */ /* NetWork InterFace */ /* Vender */ class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { //MARK: - public property //MARK: - readonly property //MARK: - getters and setters //MARK: - life cycle override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) self.commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.commonInit() } //MARK: - layout override func updateConstraints() { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ super.updateConstraints() //this line must be the last line of this method.^_^ } override func layoutSubviews() { super.layoutSubviews() /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #if DEBUG deinit { print("[\(type(of: self)) deinit]") } #endif } //MARK: - initial Methods fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { func commonInit() { self.contentView.backgroundColor = UIColor.white; } } //MARK: - private method fileprivate extension ___FILEBASENAMEASIDENTIFIER___ { } //MARK: - public method extension ___FILEBASENAMEASIDENTIFIER___ { } ================================================ FILE: filetemplete/Custom/PowerTableViewCell.xctemplate/UITableViewCellXIBSwift/___FILEBASENAME___.xib ================================================ ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default NSObject FallbackHeader #import <UIKit/UIKit.h> Values UIView Suffixes UIView View Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UIView Default false NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/UIViewObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : UIView @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/UIViewObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } - (id)initWithView:(UIView *)view { NSAssert(view, @"View must not be nil."); return [self initWithFrame:view.bounds]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - Initial Methods - (void)commonInit { /*custom view u want draw in here*/ } #pragma mark - Layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - public Method #pragma mark - private method #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : UIView @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self commonInit]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self commonInit]; } return self; } - (id)initWithView:(UIView *)view { NSAssert(view, @"View must not be nil."); return [self initWithFrame:view.bounds]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - Initial Methods - (void)commonInit { /*custom view u want draw in here*/ } #pragma mark - Layout - (void)updateConstraints { /*更新约束,自定义view应该重写此方法在其中建立constraints.*/ [super updateConstraints];//this line must be the last line of this method.^_^ } - (void)layoutSubviews { /*如果你需要更精确控制子view,而不是使用限制或autoresizing行为,就需要实现该方法。*/ } #pragma mark - public Method #pragma mark - private method #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerView.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.xib ================================================ ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/TemplateInfo.plist ================================================ Kind Xcode.IDEFoundation.TextSubstitutionFileTemplateKind Description A Cocoa Touch class. Summary A Cocoa Touch class SortOrder 1 DefaultCompletionName MyClass Platforms com.apple.platform.iphoneos Options Identifier productName Required Name Class: Description The name of the class to create Type text NotPersisted Identifier cocoaTouchSubclass Required YES Name Subclass of: Description What class to subclass in the new file Type class Default NSObject FallbackHeader #import <UIKit/UIKit.h> Values UIViewController Suffixes UIViewController ViewController Identifier XIB Name Also create XIB file Description Whether to create a XIB file with the same name Type checkbox RequiredOptions cocoaTouchSubclass UIViewController Default true NotPersisted Identifier languageChoice Required Name Language: Description The implementation language Type popup Default Objective-C Values Swift Objective-C MainTemplateFiles Swift ___FILEBASENAME___.swift Objective-C ___FILEBASENAME___.m AllowedTypes Swift public.swift-source Objective-C public.objective-c-source public.objective-c-plus-plus-source ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/UIViewControllerObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : UIViewController @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/UIViewControllerObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /*ViewController*/ /*View&&Util*/ /*model*/ /*NetWork InterFace*/ /*Vender*/ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = <#value#>; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - public Method #pragma mark - private method #pragma mark - event response #pragma mark - UITableViewDelegate #pragma mark - UITableViewDataSource //...(多个代理方法依次往下写) #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.h ================================================ //___FILEHEADER___ ___IMPORTHEADER_cocoaTouchSubclass___ NS_ASSUME_NONNULL_BEGIN @interface ___FILEBASENAMEASIDENTIFIER___ : UIViewController @end NS_ASSUME_NONNULL_END ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.m ================================================ //___FILEHEADER___ #import "___FILEBASENAME___.h" /*ViewController*/ /*View&&Util*/ /*model*/ /*NetWork InterFace*/ /*Vender*/ @interface ___FILEBASENAMEASIDENTIFIER___ () @end @implementation ___FILEBASENAMEASIDENTIFIER___ #pragma mark - life cycle - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = <#value#>; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } #ifdef DEBUG - (void)dealloc { NSLog(@"%s",__func__); } #endif #pragma mark - public Method #pragma mark - private method #pragma mark - event response #pragma mark - UITableViewDelegate #pragma mark - UITableViewDataSource //...(多个代理方法依次往下写) #pragma mark - getters and setters @end ================================================ FILE: filetemplete/Custom/PowerViewController.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.xib ================================================ ================================================ FILE: package.json ================================================ { "name": "codesnippets", "version": "1.0.0", "description": "iOS 代码规范、属性、方法、GCD、线程等代码块和控制器、单例、Model 类模版", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+ssh://git@github.com/FantasticLBP/codesnippets.git" }, "keywords": [], "author": "", "license": "ISC", "bugs": { "url": "https://github.com/FantasticLBP/codesnippets/issues" }, "homepage": "https://github.com/FantasticLBP/codesnippets#readme", "devDependencies": { "@commitlint/cli": "^8.3.5", "@commitlint/config-conventional": "^8.3.4", "husky": "^4.2.3" }, "husky": { "hooks": { "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } } } ================================================ FILE: snippets/03B5A35E-EB35-4CA6-BE35-A6CDADBF3E6D.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UICollectionViewDataSource IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UICollectionViewDataSource - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return [SDGGoodsCategoryServices sharedInstance].goods.count; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section { if (![SDGGoodsCategoryServices sharedInstance].goods.count) { return CGSizeMake(0, 0); } return CGSizeMake(self.collectionView.width, self.footerHeight); } - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { if (![SDGGoodsCategoryServices sharedInstance].goods.count){ return nil; } if ([kind isEqualToString:UICollectionElementKindSectionFooter]) { UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kReloadFooterMoreCellIdentifier forIndexPath:indexPath]; [self.loadMoreView setFrame:CGRectMake(0, 0, self.collectionView.width, self.footerHeight)]; if ([SDGGoodsCategoryServices sharedInstance].hasMore) { [self.loadMoreView changeLoadViewStatus:SDGLoadingStatus]; } else { [self.loadMoreView changeLoadViewStatus:SDGLoadNoMoreStatus]; } [view addSubview:self.loadMoreView]; return view; } return nil; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { if ([SDGGoodsCategoryServices sharedInstance].isGoodsLine) { return CGSizeMake(self.collectionView.width, 30 + 90 * (DEVICE_WIDTH / 375.0)); } else { CGFloat sizeWidth = (int) (self.collectionView.width - space * 3) / 2; CGFloat sizeHeight = (sizeWidth - 10) + (210 - 135); return CGSizeMake(sizeWidth, sizeHeight); } } //下面方法仅仅适用于ios8以上的方法 - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { [[SDGGoodsCategoryServices sharedInstance] judgeNextPage:indexPath.row]; } IDECodeSnippetIdentifier 03B5A35E-EB35-4CA6-BE35-A6CDADBF3E6D IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionViewDataSource方法组 IDECodeSnippetTitle UICollectionViewDataSource IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/03E31638-8AF1-4DBE-B31B-13B60D7F41BD.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_todo IDECodeSnippetCompletionScopes All IDECodeSnippetContents //todo: <###> IDECodeSnippetIdentifier 03E31638-8AF1-4DBE-B31B-13B60D7F41BD IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 待办事项 IDECodeSnippetTitle TodoMark IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/0694D07C-5801-4583-95A9-D0212ADFE2F0.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_Observer IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - Observer Method - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *, id> *)change context:(void *)context { } IDECodeSnippetIdentifier 0694D07C-5801-4583-95A9-D0212ADFE2F0 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 观察方法代码块标识 IDECodeSnippetTitle Observer Method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/11301976-242F-4D49-BA35-74606642A8AB.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_tableViewDatasource IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark -- UITableViewDataSource IDECodeSnippetIdentifier 11301976-242F-4D49-BA35-74606642A8AB IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UITableViewDatasource方法标识 IDECodeSnippetTitle UITableViewDatasource IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/1C77FDE1-E281-415D-97F2-141962046C7A.codesnippet ================================================ IDECodeSnippetCompletionPrefix Memory_Weakself IDECodeSnippetCompletionScopes All IDECodeSnippetContents __weak typeof(self) weakself = self; IDECodeSnippetIdentifier 1C77FDE1-E281-415D-97F2-141962046C7A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary Weak防止循环引用 IDECodeSnippetTitle Weakself IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/1DEE960F-DB0D-4266-A185-1A139ABD5DE9.codesnippet ================================================ IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, strong) SelfNavigationBar *navigationBar; IDECodeSnippetIdentifier 1DEE960F-DB0D-4266-A185-1A139ABD5DE9 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetTitle IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/209CDA3A-77C5-4506-92FE-2E1BACB97C61.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_timestamp IDECodeSnippetCompletionScopes All IDECodeSnippetContents + (long long)ccurrentTimestamp { NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ; [formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateFormatterShortStyle]; [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss SSS"]; NSDate *currentDate = [NSDate date]; return (long long)([currentDate timeIntervalSince1970]*1000); } IDECodeSnippetIdentifier 209CDA3A-77C5-4506-92FE-2E1BACB97C61 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 当前时间得到时间戳 IDECodeSnippetTitle a funtion that can generate timestamp fron current time IDECodeSnippetUserSnippet IDECodeSnippetVersion 0 ================================================ FILE: snippets/275B6FBD-789B-45C5-A04F-8A0911B47677.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_LifeCycle IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - life cycle IDECodeSnippetIdentifier 275B6FBD-789B-45C5-A04F-8A0911B47677 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 生命周期函数代码块标识 IDECodeSnippetTitle life cycle IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/277AA03D-D9EF-4EF0-8368-0A0522615226.codesnippet ================================================ IDECodeSnippetCompletionPrefix GCD_global IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ <#code#> }); IDECodeSnippetIdentifier 277AA03D-D9EF-4EF0-8368-0A0522615226 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary GCD global queue IDECodeSnippetTitle GCD_global IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/2B2A78A6-3DB5-4D1C-8401-B0C4108F3544.codesnippet ================================================ IDECodeSnippetCompletionPrefix GCD_Main IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_async(dispatch_get_main_queue(), ^{ <#code#> }); IDECodeSnippetIdentifier 2B2A78A6-3DB5-4D1C-8401-B0C4108F3544 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary GCD Maint queue block IDECodeSnippetTitle GCD_Main IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/2B88F869-D37D-4451-90C6-83923D0942D6.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_responseMethods IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - response method IDECodeSnippetIdentifier 2B88F869-D37D-4451-90C6-83923D0942D6 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 动作响应事件代码块标识 IDECodeSnippetTitle response method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/2D5BB815-5A58-4CD2-A636-572F3331B1B3.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UIScrollViewDelegate IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { } IDECodeSnippetIdentifier 2D5BB815-5A58-4CD2-A636-572F3331B1B3 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UIScrollViewDelegate方法组 IDECodeSnippetTitle UIScrollViewDelegate IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/2E2654CC-E49E-4F6C-BD26-6E4F0BCCC4CD.codesnippet ================================================ IDECodeSnippetCompletionPrefix UICollectionView_init IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (UICollectionView *)collectioView { if (!_collectioView) { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(<#width#>, <#height#>); layout.minimumLineSpacing = <#spacing#>; layout.minimumInteritemSpacing = <#spacing#>; _collectioView = [[UICollectionView alloc] initWithFrame:CGRectMake(<#originX#>, <#origiY#>, <#width#>, <#height#>) collectionViewLayout:layout]; _collectioView.delegate = self; _collectioView.dataSource = self; _collectioView.backgroundColor = [UIColor blackColor]; [_collectioView registerClass:[<#CollectionViewCellClass#> class] forCellWithReuseIdentifier:<#KReuseCellIdentifier#>]; } return _collectioView; } IDECodeSnippetIdentifier 2E2654CC-E49E-4F6C-BD26-6E4F0BCCC4CD IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionView懒加载快速初始化 IDECodeSnippetTitle UICollectionView init IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/33153DCC-8748-4AE2-8832-4EA2BCFA79E2.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UICollectionViewDatasource IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark -- UICollectionViewDelegate - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return <#count#>; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { <#CollectionViewCell#> *cell = collectionView dequeueReusableCellWithReuseIdentifier:<#KReuseCellIdentifier#> forIndexPath:indexPath]; return cell; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return <#count#>; } IDECodeSnippetIdentifier 33153DCC-8748-4AE2-8832-4EA2BCFA79E2 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionViewDatasource方法组 IDECodeSnippetTitle UICollectionViewDatasource IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/371D1B02-BB6E-4601-AB18-6BEE7DF791D9.codesnippet ================================================ IDECodeSnippetCompletionPrefix Memory_Strongself IDECodeSnippetCompletionScopes All IDECodeSnippetContents __strong typeof(<#weakself#>) = <#weakself#>; IDECodeSnippetIdentifier 371D1B02-BB6E-4601-AB18-6BEE7DF791D9 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary Strong修饰自己 IDECodeSnippetTitle StrongSelf IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/37B6B32D-BE8C-4A6C-A426-A31715E36377.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_Encode IDECodeSnippetCompletionScopes All IDECodeSnippetContents #define PCT_DECODE(decoder, dataType, keyName) \ { \ _##keyName = [decoder decode##dataType##ForKey:NSStringFromSelector(@selector(keyName))]; \ }; #define PCT_ENCODE(aCoder, dataType, key) \ { \ [aCoder encode##dataType:_##key forKey:NSStringFromSelector(@selector(key))]; \ }; IDECodeSnippetIdentifier 37B6B32D-BE8C-4A6C-A426-A31715E36377 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 给归档协议的方法增加宏,使用起来超方便 IDECodeSnippetTitle EncodeAndDecode IDECodeSnippetUserSnippet IDECodeSnippetVersion 0 ================================================ FILE: snippets/3D903ED6-6B9E-481C-B56F-3DBC997647EA.codesnippet ================================================ IDECodeSnippetCompletionPrefix delegate_methodMark IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - <#delegate method#> IDECodeSnippetIdentifier 3D903ED6-6B9E-481C-B56F-3DBC997647EA IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 代理方法代码块标识 IDECodeSnippetTitle delegate method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/420DCB87-CF51-4430-AF4D-FABDFCBC990A.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UITableviewDelegate IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UITableViewDelegate - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { SDGCategoryModel *cateModel = [[SDGGoodsCategoryServices sharedInstance].categories[indexPath.section] children][indexPath.row]; if (cateModel.isSelect) { CGSize size = [cateModel.name xq_sizeWithMaxWith:k_firstCategoryTableViewW - 12 textfont:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium]]; return size.height + 29.f; } else { CGSize size = [cateModel.name xq_sizeWithMaxWith:k_firstCategoryTableViewW textfont:[UIFont systemFontOfSize:12]]; return size.height + 29.f; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { SDGCategoryModel *cateModel = [SDGGoodsCategoryServices sharedInstance].categories[section]; if (cateModel.isSelect) { CGSize size = [cateModel.name xq_sizeWithMaxWith:80 - 5.5 textfont:[UIFont systemFontOfSize:17 weight:UIFontWeightMedium]]; return size.height + 29.f; } else { CGSize size = [cateModel.name xq_sizeWithMaxWith:80 - 5.5 textfont:[UIFont systemFontOfSize:14]]; return size.height + 29.f; } } IDECodeSnippetIdentifier 420DCB87-CF51-4430-AF4D-FABDFCBC990A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UITableViewDelegate方法组 IDECodeSnippetTitle UITableViewDelegate IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/4B823738-51F6-4577-B6F4-A3743C421954.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_block IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, copy) <#returnType#> (^<#Block#>)(<#parType#>); IDECodeSnippetIdentifier 4B823738-51F6-4577-B6F4-A3743C421954 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary block 作为属性 IDECodeSnippetTitle block property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/52A5D59C-7D4E-4E93-A0BB-D826B89BDBE4.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_categoryProperty IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (NSString*)cmn_requestId { return objc_getAssociatedObject(self, _cmd); } - (void)setCmn_requestId:(NSString*)requestId { objc_setAssociatedObject(self, @selector(cmn_requestId),requestId, OBJC_ASSOCIATION_COPY_NONATOMIC); } IDECodeSnippetIdentifier 52A5D59C-7D4E-4E93-A0BB-D826B89BDBE4 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 给 Category 添加属性 IDECodeSnippetTitle a function codesnippet that can add property to class category IDECodeSnippetUserSnippet IDECodeSnippetVersion 0 ================================================ FILE: snippets/6521D6E4-60D5-4B65-8BB8-B6F9214786E4.codesnippet ================================================ IDECodeSnippetCompletionPrefix Thread_address IDECodeSnippetCompletionScopes All IDECodeSnippetContents [NSThread callStackReturnAddresses]; IDECodeSnippetIdentifier 6521D6E4-60D5-4B65-8BB8-B6F9214786E4 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 线程调用对象的地址 IDECodeSnippetTitle NSThread stack address IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/6E3D9C27-EADC-4169-8262-3EABCEF76F26.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_privateMethod IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - private method IDECodeSnippetIdentifier 6E3D9C27-EADC-4169-8262-3EABCEF76F26 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 私有方法代码块标识 IDECodeSnippetTitle Private method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/704FA5E6-6F39-4B1D-AFCF-CC6A471BE8DA.codesnippet ================================================ IDECodeSnippetCompletionPrefix GCD_concurrentQueue IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); IDECodeSnippetIdentifier 704FA5E6-6F39-4B1D-AFCF-CC6A471BE8DA IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary GCD并行队列 IDECodeSnippetTitle concurrentQueue IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/70B72C45-F1A5-4BC1-85F2-1315CB26B6E4.codesnippet ================================================ IDECodeSnippetCompletionPrefix GCD_concurrentQueue2 IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_queue_t concurrentQueue = dispatch_queue_create(<####>, DISPATCH_QUEUE_CONCURRENT); IDECodeSnippetIdentifier 70B72C45-F1A5-4BC1-85F2-1315CB26B6E4 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary GCD并行队列创建方法2 IDECodeSnippetTitle concurrentQueue2 IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/745A7446-3A07-4214-87A0-539DD6464A37.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_init IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - Initial Methods IDECodeSnippetIdentifier 745A7446-3A07-4214-87A0-539DD6464A37 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 初始化方法标识 IDECodeSnippetTitle initial method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/74B99378-1AD3-45A4-85E5-AA0AD8CBEF57.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_delegate IDECodeSnippetCompletionScopes ClassInterfaceMethods IDECodeSnippetContents @property (nonatomic, weak) id<<#delegate#>> delegate; IDECodeSnippetIdentifier 74B99378-1AD3-45A4-85E5-AA0AD8CBEF57 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary delegate 作为属性 IDECodeSnippetTitle delegate IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/7502B441-E8B3-46DE-A0E9-310689F3E281.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_queueLock IDECodeSnippetCompletionScopes All IDECodeSnippetContents @synchronized(self){ } IDECodeSnippetIdentifier 7502B441-E8B3-46DE-A0E9-310689F3E281 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 线程同步锁 IDECodeSnippetTitle threadlock IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/788CE23F-0ED2-4D3A-8F0B-29C9857EC5E9.codesnippet ================================================ IDECodeSnippetCompletionPrefix UITableView_init IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (UITableView *)tableview { if (!_tableview) { _tableview = [[UITableView alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>) style:UITableViewStylePlain]; _tableview.delegate = self; _tableview.dataSource = self; _tableview.tableFooterView = [UIView new]; [_tableview registerClass:[<#CellClass#> class] forCellReuseIdentifier:<#KReuseCellIdentifier#>]; } return _tableview; } IDECodeSnippetIdentifier 788CE23F-0ED2-4D3A-8F0B-29C9857EC5E9 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UITableView快速初始化 IDECodeSnippetTitle UITableViewInit IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/8A98B142-2FDB-465E-A80B-C91A1F1910AB.codesnippet ================================================ IDECodeSnippetCompletionPrefix Delegate_respond IDECodeSnippetCompletionScopes All IDECodeSnippetContents if (self.delegate && [self.delegate respondsToSelector:@selector(<#methodName#>)]) { [self.delegate <#methodName#>]; } IDECodeSnippetIdentifier 8A98B142-2FDB-465E-A80B-C91A1F1910AB IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 代理对象安全响应方法 IDECodeSnippetTitle delegate responsd selector IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/8AE1227B-6823-4CD8-9705-F52BF113CE8F.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_PublicMethod IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - public Method IDECodeSnippetIdentifier 8AE1227B-6823-4CD8-9705-F52BF113CE8F IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 可公开访问方法代码块标识 IDECodeSnippetTitle Public Method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/8D5EFC11-0FFE-4180-8127-FF3ACC9B5705.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_template IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark -- <#mark#> IDECodeSnippetIdentifier 8D5EFC11-0FFE-4180-8127-FF3ACC9B5705 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary mark 代码块 IDECodeSnippetTitle mark IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/928529DE-46F1-4522-90D2-2743665C1A2C.codesnippet ================================================ IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, copy) NSDictionary *<#name#>; IDECodeSnippetIdentifier 928529DE-46F1-4522-90D2-2743665C1A2C IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetTitle prop_NSDictonary IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A3D9F9B6-3C1D-441A-99AF-49F3CD9A00D7.codesnippet ================================================ IDECodeSnippetCompletionPrefix lifecycle_dealloc IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (void)dealloc { NSLog(@"%s",__func__); } IDECodeSnippetIdentifier A3D9F9B6-3C1D-441A-99AF-49F3CD9A00D7 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 对象销毁的方法 IDECodeSnippetTitle dealloc IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A6510304-574A-4A4E-BAED-577B1B314377.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UICollectionViewDelegate IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark -- UICollectionViewDatasource - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { } IDECodeSnippetIdentifier A6510304-574A-4A4E-BAED-577B1B314377 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionDelegate方法组 IDECodeSnippetTitle UICollectionViewDelegate IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A6D7B6F4-4E4F-486C-A8B8-7E068F5631FB.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_notification IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - Notification Method IDECodeSnippetIdentifier A6D7B6F4-4E4F-486C-A8B8-7E068F5631FB IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 通知方法代码块标识 IDECodeSnippetTitle Notification Method IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A7135568-6312-4234-9838-DF2086CBBA4A.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_AppLaunchNotificate IDECodeSnippetCompletionScopes All IDECodeSnippetContents + (void)load { __weak NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ //DOSOMETHING [center removeObserver:observer]; }); }]; } IDECodeSnippetIdentifier A7135568-6312-4234-9838-DF2086CBBA4A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary App 启动通知 IDECodeSnippetTitle App launch notification IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A79C2ADB-2177-48C0-B2A6-449A6928EA7D.codesnippet ================================================ IDECodeSnippetCompletionPrefix propAssign IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, assign) <#type#> <#value#>; IDECodeSnippetIdentifier A79C2ADB-2177-48C0-B2A6-449A6928EA7D IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetTitle prop_assign IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/A92834F3-256A-4508-9CC2-57B242780B4A.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_Copy IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, copy) <#Class#> *<#object#>; IDECodeSnippetIdentifier A92834F3-256A-4508-9CC2-57B242780B4A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary copy属性的代码块 IDECodeSnippetTitle copy property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/AE16B32F-55B1-4757-AE9C-F392F1115EEB.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_assign IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, assign) <#Class#> <#object#>; IDECodeSnippetIdentifier AE16B32F-55B1-4757-AE9C-F392F1115EEB IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 基本数据类型属性修饰 IDECodeSnippetTitle assign property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/B21D4EF7-1AFB-4F78-B6E4-4180475A3EE5.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_NSDataAES IDECodeSnippetCompletionScopes All IDECodeSnippetContents #import <CommonCrypto/CommonCryptor.h> /// 对 NSData 增加 AES 加解密的能力。CBC加密模式,安全性更高 @implementation NSData (PCTAES) /** 对 NSData 数据进行 AES 加密 @param key 16位参数 @param Iv 16位参数 @return 加密结果 */ - (NSData *)pct_AES128EncryptWithKey:(NSString *)key Iv:(NSString *)Iv { char keyPtr[kCCKeySizeAES128 + 1]; bzero(keyPtr, sizeof(keyPtr)); [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; char ivPtr[kCCKeySizeAES128 + 1]; memset(ivPtr, 0, sizeof(ivPtr)); [Iv getCString:ivPtr maxLength:sizeof(ivPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [self length]; size_t bufferSize = dataLength + kCCBlockSizeAES128; void *buffer = malloc(bufferSize); size_t numBytesEncrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCBlockSizeAES128, ivPtr, [self bytes], dataLength, buffer, bufferSize, &numBytesEncrypted); if (cryptStatus == kCCSuccess) { return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted]; } free(buffer); return nil; } /** 对 NSData 数据进行 AES 解密 @param key 16位参数 @param Iv 16为位参数 @return 解密结果 */ - (NSData *)pct_AES128DecryptWithKey:(NSString *)key gIv:(NSString *)Iv { char keyPtr[kCCKeySizeAES128 + 1]; bzero(keyPtr, sizeof(keyPtr)); [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; char ivPtr[kCCKeySizeAES128 + 1]; memset(ivPtr, 0, sizeof(ivPtr)); [Iv getCString:ivPtr maxLength:sizeof(ivPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [self length]; size_t bufferSize = dataLength + kCCBlockSizeAES128; void *buffer = malloc(bufferSize); size_t numBytesDecrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCBlockSizeAES128, ivPtr, [self bytes], dataLength, buffer, bufferSize, &numBytesDecrypted); if (cryptStatus == kCCSuccess) { return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted]; } free(buffer); return nil; } @end IDECodeSnippetIdentifier B21D4EF7-1AFB-4F78-B6E4-4180475A3EE5 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 给 NSData 增加 AES 加解密功能 IDECodeSnippetTitle AES with NSData IDECodeSnippetUserSnippet IDECodeSnippetVersion 0 ================================================ FILE: snippets/B3F0923F-776E-4B13-95BB-2D80B4D771AA.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_Fixme IDECodeSnippetCompletionScopes All IDECodeSnippetContents //FIXME: <#Something will fix in a short future#> IDECodeSnippetIdentifier B3F0923F-776E-4B13-95BB-2D80B4D771AA IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 待修复事项标签 IDECodeSnippetTitle Fixme mark IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/B4802492-A5F7-475B-A80B-1A414A7EB42A.codesnippet ================================================ IDECodeSnippetCompletionPrefix Thread_Stacks IDECodeSnippetCompletionScopes All IDECodeSnippetContents [NSThread callStackSymbols]; IDECodeSnippetIdentifier B4802492-A5F7-475B-A80B-1A414A7EB42A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 线程调用栈 IDECodeSnippetTitle NSThread stack Infos IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/BCBFB1D9-5EDD-4F8A-87A7-B087307C1CA6.codesnippet ================================================ IDECodeSnippetCompletionPrefix Property_navigationBar IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, strong) SelfNavigationBar *navigationBar; IDECodeSnippetIdentifier BCBFB1D9-5EDD-4F8A-87A7-B087307C1CA6 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary NavigationBar property IDECodeSnippetTitle NavigationBar_Property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/BF9C74C4-D9CC-442C-9343-C9295D448CAF.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UICollectionViewDelegateFlowLayout IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UICollectionViewDelegateFlowLayout - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return [SDGGoodsCategoryServices sharedInstance].isGoodsLine ? UIEdgeInsetsMake(0, 0, 0, 0) : UIEdgeInsetsMake(space, space, space, space); } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return [SDGGoodsCategoryServices sharedInstance].isGoodsLine ? 0 : space; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return [SDGGoodsCategoryServices sharedInstance].isGoodsLine ? 0 : space; } IDECodeSnippetIdentifier BF9C74C4-D9CC-442C-9343-C9295D448CAF IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionViewDelegateFlowLayout方法组 IDECodeSnippetTitle UICollectionViewDelegateFlowLayout IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/C1C29A6B-AADD-4D4B-9608-2BB78D6CB38A.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_strong IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, strong) <#Class#> *<#object#>; IDECodeSnippetIdentifier C1C29A6B-AADD-4D4B-9608-2BB78D6CB38A IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary strong 属性的代码块 IDECodeSnippetTitle strong property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/C21AA954-1018-41C7-A9C4-CF0F0481B64F.codesnippet ================================================ IDECodeSnippetCompletionPrefix cell-cellIdentifier IDECodeSnippetCompletionScopes All IDECodeSnippetContents static NSString *<#CellID#> = <#CellID#> ; IDECodeSnippetIdentifier C21AA954-1018-41C7-A9C4-CF0F0481B64F IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 注册TableViewCell的静态字符串变量 IDECodeSnippetTitle UITableViewCellID IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/C25DBAAC-E555-4159-840B-6CABA292EE03.codesnippet ================================================ IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - Initial Methods IDECodeSnippetIdentifier C25DBAAC-E555-4159-840B-6CABA292EE03 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UIView的 IDECodeSnippetTitle View Initial IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/C3821029-7680-4D9E-8247-857D54278DB3.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_GetterSetter IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - getters and setters IDECodeSnippetIdentifier C3821029-7680-4D9E-8247-857D54278DB3 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 属性的存取方法 IDECodeSnippetTitle getter && setter IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/C7FF27C0-7E66-4A29-80D4-1285A89F93AF.codesnippet ================================================ IDECodeSnippetCompletionPrefix Class_Interface IDECodeSnippetCompletionScopes All IDECodeSnippetContents @interface <#Class#>() @end IDECodeSnippetIdentifier C7FF27C0-7E66-4A29-80D4-1285A89F93AF IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary interface 代码块 IDECodeSnippetTitle interface IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/D7227C17-6368-4FA9-BCD1-D354BC129AD9.codesnippet ================================================ IDECodeSnippetCompletionPrefix UILabel_Init IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (UILabel *)label { if (!_label) { _label = [[UILabel alloc] initWithFrame:CGRectMake(<#originX#>, <#originY#>, <#width#>, <#height#>)]; _label.font = [UIFont systemFontOfSize:<#fontsize#>]; _label.text = <#text#>; _label.textColor = [UIColor <#color#>]; _label.textAlignment = NSTextAlignmentCenter; _label.backgroundColor = [UIColor <#color#>]; } return _label; } IDECodeSnippetIdentifier D7227C17-6368-4FA9-BCD1-D354BC129AD9 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UILabel快速懒加载初始化 IDECodeSnippetTitle UILabelInit IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/E6B15072-CD4B-4DE5-BE9D-6306DB609A32.codesnippet ================================================ IDECodeSnippetCompletionPrefix propCopy IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, copy) <#type#> *<#value#>; IDECodeSnippetIdentifier E6B15072-CD4B-4DE5-BE9D-6306DB609A32 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetTitle prop_copy IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/E87096D8-7617-467F-A3AB-742D7E36ED55.codesnippet ================================================ IDECodeSnippetCompletionPrefix property_weak IDECodeSnippetCompletionScopes All IDECodeSnippetContents @property (nonatomic, weak) <#Class#> *<#object#>; IDECodeSnippetIdentifier E87096D8-7617-467F-A3AB-742D7E36ED55 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary weak property的代码块 IDECodeSnippetTitle weak property IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/E8E74582-3E40-43F4-82E4-273EBC57372F.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_mainQueue IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_sync(dispatch_get_main_queue(), ^{ }); IDECodeSnippetIdentifier E8E74582-3E40-43F4-82E4-273EBC57372F IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 主线程操作 IDECodeSnippetTitle mainThread IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/E935C1C4-D472-4D34-B5AD-86D20EBC61BC.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_lifecycle IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - life cycle - (void)viewWillAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = <#value#>; } - (void)viewWillDisappear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)dealloc { NSLog(@"%s",__func__); } IDECodeSnippetIdentifier E935C1C4-D472-4D34-B5AD-86D20EBC61BC IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 生命周期函数组模版 IDECodeSnippetTitle Life cycle Methods IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/F07D17AE-4941-475F-BB33-4F9F27CC69F3.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_UICollectionViewDelegate IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UICollectionViewDelegate IDECodeSnippetIdentifier F07D17AE-4941-475F-BB33-4F9F27CC69F3 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionViewDelegate方法标识 IDECodeSnippetTitle UICollectionViewDelegate IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/F20FD025-017A-4B29-B450-71A1C4CAB992.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_UITableViewDatasource IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return <#count#>; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return <#count#>; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { <#CellClass#> *cell = [tableView dequeueReusableCellWithIdentifier:<#KReuseIdentifier#> forIndexPath:indexPath]; return cell; } IDECodeSnippetIdentifier F20FD025-017A-4B29-B450-71A1C4CAB992 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UITableViewDatasource关键方法组 IDECodeSnippetTitle UITableViewDatasourceMethods IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/F7811228-EC34-4A6E-A926-558A637782E1.codesnippet ================================================ IDECodeSnippetCompletionPrefix UIButton_Init IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (UIButton *)button { if (!_button) { _button = [UIButton buttonWithType:UIButtonTypeCustom]; _button.frame = CGRectMake(<#originX#>, <#originY#>, <#width#>, <#height#>); [_button setTitle:<#title#> forState:UIControlStateNormal]; [_button setTitleColor:<#Color#> forState:UIControlStateNormal]; [_button addTarget:self action:@selector(<#metodName#>) forControlEvents:UIControlEventTouchUpInside]; } return _button; } IDECodeSnippetIdentifier F7811228-EC34-4A6E-A926-558A637782E1 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UIButton快速懒加载初始化 IDECodeSnippetTitle UIButtonInit IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/F856017E-E797-4E46-9B9D-BC6F2E454808.codesnippet ================================================ IDECodeSnippetCompletionPrefix Protocol IDECodeSnippetCompletionScopes All IDECodeSnippetContents @class <#Class#>; @protocol <#Delegate#><NSObject> @required - (void)bidInfoCell:(delegate *)bidInfoCell didClickWithCompanyModel:(CompanyModel *)companymodel; @end IDECodeSnippetIdentifier F856017E-E797-4E46-9B9D-BC6F2E454808 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 协议的声明 IDECodeSnippetTitle Protocol desrlation IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/FC9F0763-DC79-4E21-B15A-092C04DB2C40.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_MethodsGroup IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - life cycle #pragma mark - public Method #pragma mark - private method #pragma mark - event response #pragma mark - UITableViewDelegate #pragma mark - UITableViewDataSource #pragma mark - getters and setters IDECodeSnippetIdentifier FC9F0763-DC79-4E21-B15A-092C04DB2C40 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary 控制器方法组顺序模版 IDECodeSnippetTitle Methods Group IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/FD779057-D489-4726-BA41-C3715D7D697F.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_UICollectionViewDataSource IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark -- UICollectionViewDataSource IDECodeSnippetIdentifier FD779057-D489-4726-BA41-C3715D7D697F IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UICollectionViewDataSource 方法标识 IDECodeSnippetTitle UICollectionViewDataSource IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/FDAC1BE2-9CED-4A84-A821-BD8BCA8428C5.codesnippet ================================================ IDECodeSnippetCompletionPrefix Mark_UIViewLayout IDECodeSnippetCompletionScopes All IDECodeSnippetContents #pragma mark - Layout IDECodeSnippetIdentifier FDAC1BE2-9CED-4A84-A821-BD8BCA8428C5 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary UIView布局方法标识 IDECodeSnippetTitle UIView Layout mark IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/FEDC91B5-80F6-4C66-AF76-67871903EE51.codesnippet ================================================ IDECodeSnippetCompletionPrefix GCD-SerialQueue IDECodeSnippetCompletionScopes All IDECodeSnippetContents dispatch_queue_t serialQueue = dispatch_queue_create("com.lbp.download", DISPATCH_QUEUE_SERIAL); IDECodeSnippetIdentifier FEDC91B5-80F6-4C66-AF76-67871903EE51 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary GCD串行队列 IDECodeSnippetTitle serialQueue IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/FF4BEF07-88F0-49F8-A3AA-33A90F2F6411.codesnippet ================================================ IDECodeSnippetCompletionPrefix NavigationBar_init IDECodeSnippetCompletionScopes All IDECodeSnippetContents - (SelfNavigationBar *)navigationBar { if (!_navigationBar) { _navigationBar = [[SelfNavigationBar alloc] initBarWithFrame:CGRectMake(0, 0, self.view.width, XQ_BAR_NAV_STATUS_HEIGHT)]; _navigationBar.backgroundColor = [UIColor clearColor]; [_navigationBar setLeftButtonWithImage:[UIImage imageNamed:@"LH_NavigationBar_BackIconBlack"] withControlState:UIControlStateNormal]; @weakify(self); [_navigationBar setLeftButtonWithAction:^{ @strongify(self); // ...左侧返回按钮事件 [self.navigationController popViewControllerAnimated:YES]; } withControlerEvent:UIControlEventTouchUpInside]; [_navigationBar setLeftButtonWithTitle:<#buttonTitle#> withControlState:UIControlStateNormal]; _navigationBar.leftButton.titleLabel.font = [UIFont boldSystemFontOfSize:17]; [_navigationBar setTitleBarLeftTextColor:[UIColor whiteColor] IconColor:nil]; } return _navigationBar; } IDECodeSnippetIdentifier FF4BEF07-88F0-49F8-A3AA-33A90F2F6411 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Generic IDECodeSnippetSummary NavigationBar quick init IDECodeSnippetTitle NavigationBar初始化 IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/headerdoc.codesnippet ================================================ IDECodeSnippetCompletionPrefix document_method IDECodeSnippetCompletionScopes ClassInterfaceMethods IDECodeSnippetContents /** <#description#> @param <#parameter#> @returns <#retval#> @exception <#throws#> */ IDECodeSnippetIdentifier 0A716188-D622-4919-8E44-687A79938994 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C-Plus-Plus IDECodeSnippetSummary Header Doc style block IDECodeSnippetTitle doc IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: snippets/singleton.codesnippet ================================================ IDECodeSnippetCompletionPrefix Method_singleton IDECodeSnippetCompletionScopes ClassImplementation IDECodeSnippetContents + (instancetype)sharedInstance { static <#Class#> *_sharedInstance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _sharedInstance = [[<#Class#> alloc] init]; }); return _sharedInstance; } IDECodeSnippetIdentifier EAF76F59-D8FE-478A-B9CD-5A8196140A42 IDECodeSnippetLanguage Xcode.SourceCodeLanguage.Objective-C IDECodeSnippetSummary 单例快捷代码块 IDECodeSnippetTitle singleton IDECodeSnippetUserSnippet IDECodeSnippetVersion 2 ================================================ FILE: syncSnippets.sh ================================================ # 强制删除传递的参数文件夹,然后逐层创建文件夹 function mkDirAbsolutely { rm -rf $1 mkdir -p $1 } # 从云端下载代码块 function downloadCodesnippetsFromGit { git clone $1 } # 先给 Xcode 的代码块的文件夹设置权限; # 777 和 775 分别代表三种用户身份的文件权限。(文件所有者、文件所属组、其他用户)7=4+2+1 可读可写可执行;6=4+2可读可写;5=1+4;可读可执行 function moveCodeSnippetsToXcodeSnippetsFolder { chmod 775 ~/Library/Developer/Xcode/UserData/CodeSnippets/ mv -f ./snippets/* ~/Library/Developer/Xcode/UserData/CodeSnippets/ } # 先给 Xcode 的 File templates 文件夹设置权限 # 再将从云端下载下来的文件模版文件夹写入移动到 Xcode 下的 File Templates 文件夹下 function moveFileTemplatesToXcodeFileTemplatesFolder { # 记录当前绝对路径 basepath=$(cd `dirname $0`; pwd) # 进入Xcode系统类文件模版路径 cd cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File\ Templates/ # 系统文件夹授权 sudo chmod 777 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File\ Templates/ mkDirAbsolutely Custom cd Custom # 再切换到当前脚本所在的文件夹下 cd $basepath # 将从云端下载下来的代码模版移动到Xcode系统的模版文件夹下 mv -f ./filetemplete/Custom/* /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File\ Templates/Custom/ } # 强制删除文件夹 function deleteTheFolderAbsolutely { rm -fr $1 } :<