├── .DS_Store ├── Application ├── .DS_Store └── CodeCreater.dmg ├── README.md ├── ZXCodeCreater.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── zx.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── zx.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ZXCodeCreater.xcscheme │ └── xcschememanagement.plist ├── ZXCodeCreater ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── ZXCodeCreaterIcon.png │ │ └── ZXCodeCreaterIcon@2x.png │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── FileContent │ ├── ApiManager │ │ └── .DS_Store │ ├── Ctrler │ │ └── .DS_Store │ ├── Reformer │ │ └── .DS_Store │ └── View │ │ └── .DS_Store ├── Info.plist ├── Resource │ ├── .DS_Store │ ├── IntroductionDiagram.png │ ├── IntroductionDiagram.sketch │ ├── Original.sketch │ ├── ZXCodeCreaterIcon.png │ └── ZXCodeCreaterIcon@2x.png ├── Ulits │ ├── FileHandle.h │ ├── FileHandle.m │ ├── FileManager.h │ └── FileManager.m ├── ViewController.h ├── ViewController.m └── main.m └── ZXCodeCreaterTestModule ├── .DS_Store ├── ZXCodeCreaterTestCtrler ├── .DS_Store ├── ZXCodeCreaterTestView │ ├── ZXCodeCreaterTestView.h │ └── ZXCodeCreaterTestView.m ├── ZXCodeCreaterTestViewController.h └── ZXCodeCreaterTestViewController.m └── ZXCodeCreaterTestManager ├── ZXCodeCreaterTestManager.h └── ZXCodeCreaterTestManager.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/.DS_Store -------------------------------------------------------------------------------- /Application/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/Application/.DS_Store -------------------------------------------------------------------------------- /Application/CodeCreater.dmg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/Application/CodeCreater.dmg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeCreater 2 | ## 背景: 3 | 1. 写代码的时候,可能经常会遇到多个模块中基础内容都是想似的,例如,你可能很多文件中都会懒加载一个UITableView实例对象,遵守UITableViewDelegate、UITableViewDataSource协议并实现方法,或者你在每一个类中都要写一个方法用来统一管理UI,用一个方法统一用来管理Layout,或者各种#pragma mark - ####; 4 | 2. 类似的东西,处理大概如下: 5 | 1).没有抽离过公用代码,用的时候重新敲一遍吧; 6 | 2).没有抽离过公用代码,用的时候把以前的复制过来,多余的删掉吧; 7 | 3).抽离过公用代码,用的时候直接复制修改类名拖过来就好啦; 8 | 4).抽离过公用代码,用脚本生成需要的文件; 9 | 3. 于是乎,我让它进化到了第五种:利用NSFileManager相关知识,封以MacOS外壳;能够通过通用模板生成目标文件夹及文件; 10 | 11 | 12 | ## 思路 13 | 其实在我最开始打算写这个小工具的时候,我是创建了很多个类的,准备一个一个的类用字符串拼接而成,并且当时想的可能写出来也不会适合大众模板,只会死死的停留在一个模板上; 14 | 15 | 之后突然发现,所谓的快速生成代码,对比之前的文件,改变的仅仅就是类名,文件名;然后就建立了模板,直接遍历模板中的文件夹及其文件,将模板中原来的字段替换成新字段就行了; 16 | 17 | 代码也很简单,想知其所以然的可以去看看; 18 | 19 | 20 | ## 贴金 21 | 1. 快速生成所需文件夹及其文件代码,节省时间,提升开发效率; 22 | 2. 一个模子刻出来的东西,风格统一; 23 | 24 | 25 | ## 一图概全 26 | ![image](https://github.com/czhen09/ZXCodeCreater/blob/master/ZXCodeCreater/Resource/IntroductionDiagram.png) 27 | 28 | 29 | ## 结语 30 | 1. 使用之前,你们得为自己准备一份通用模板; 31 | 如果暂时没有,可以通过文件目录下的ZXCodeCreaterTestModule文件夹进行测试; 32 | 2. dmg软件包在Application目录下; 33 | 2. 让CodeCreater去接受你们的考验吧! 34 | 3. 使用愉快,谢谢star! 35 | 4. [简书](http://www.jianshu.com/p/55c0b79b20d5) 36 | -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FB0157401EFFA4E600D3AC5F /* FileHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = FB01573F1EFFA4E600D3AC5F /* FileHandle.m */; }; 11 | FBBCBC421EFD44D30009C244 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FBBCBC411EFD44D30009C244 /* AppDelegate.m */; }; 12 | FBBCBC451EFD44D30009C244 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FBBCBC441EFD44D30009C244 /* main.m */; }; 13 | FBBCBC481EFD44D30009C244 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBBCBC471EFD44D30009C244 /* ViewController.m */; }; 14 | FBBCBC4A1EFD44D30009C244 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FBBCBC491EFD44D30009C244 /* Assets.xcassets */; }; 15 | FBBCBC4D1EFD44D30009C244 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FBBCBC4B1EFD44D30009C244 /* Main.storyboard */; }; 16 | FBBCBC571EFD49C00009C244 /* FileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBBCBC561EFD49C00009C244 /* FileManager.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | FB01573E1EFFA4E600D3AC5F /* FileHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileHandle.h; sourceTree = ""; }; 21 | FB01573F1EFFA4E600D3AC5F /* FileHandle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileHandle.m; sourceTree = ""; }; 22 | FBBCBC3D1EFD44D30009C244 /* ZXCodeCreater.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZXCodeCreater.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | FBBCBC401EFD44D30009C244 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | FBBCBC411EFD44D30009C244 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | FBBCBC441EFD44D30009C244 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | FBBCBC461EFD44D30009C244 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | FBBCBC471EFD44D30009C244 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | FBBCBC491EFD44D30009C244 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | FBBCBC4C1EFD44D30009C244 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | FBBCBC4E1EFD44D30009C244 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | FBBCBC551EFD49C00009C244 /* FileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileManager.h; sourceTree = ""; }; 32 | FBBCBC561EFD49C00009C244 /* FileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileManager.m; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | FBBCBC3A1EFD44D30009C244 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | FBBCBC341EFD44D30009C244 = { 47 | isa = PBXGroup; 48 | children = ( 49 | FBBCBC3F1EFD44D30009C244 /* ZXCodeCreater */, 50 | FBBCBC3E1EFD44D30009C244 /* Products */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | FBBCBC3E1EFD44D30009C244 /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | FBBCBC3D1EFD44D30009C244 /* ZXCodeCreater.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | FBBCBC3F1EFD44D30009C244 /* ZXCodeCreater */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | FBBCBC541EFD49C00009C244 /* Ulits */, 66 | FBBCBC401EFD44D30009C244 /* AppDelegate.h */, 67 | FBBCBC411EFD44D30009C244 /* AppDelegate.m */, 68 | FBBCBC461EFD44D30009C244 /* ViewController.h */, 69 | FBBCBC471EFD44D30009C244 /* ViewController.m */, 70 | FBBCBC491EFD44D30009C244 /* Assets.xcassets */, 71 | FBBCBC4B1EFD44D30009C244 /* Main.storyboard */, 72 | FBBCBC4E1EFD44D30009C244 /* Info.plist */, 73 | FBBCBC431EFD44D30009C244 /* Supporting Files */, 74 | ); 75 | path = ZXCodeCreater; 76 | sourceTree = ""; 77 | }; 78 | FBBCBC431EFD44D30009C244 /* Supporting Files */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | FBBCBC441EFD44D30009C244 /* main.m */, 82 | ); 83 | name = "Supporting Files"; 84 | sourceTree = ""; 85 | }; 86 | FBBCBC541EFD49C00009C244 /* Ulits */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | FBBCBC551EFD49C00009C244 /* FileManager.h */, 90 | FBBCBC561EFD49C00009C244 /* FileManager.m */, 91 | FB01573E1EFFA4E600D3AC5F /* FileHandle.h */, 92 | FB01573F1EFFA4E600D3AC5F /* FileHandle.m */, 93 | ); 94 | path = Ulits; 95 | sourceTree = ""; 96 | }; 97 | /* End PBXGroup section */ 98 | 99 | /* Begin PBXNativeTarget section */ 100 | FBBCBC3C1EFD44D30009C244 /* ZXCodeCreater */ = { 101 | isa = PBXNativeTarget; 102 | buildConfigurationList = FBBCBC511EFD44D30009C244 /* Build configuration list for PBXNativeTarget "ZXCodeCreater" */; 103 | buildPhases = ( 104 | FBBCBC391EFD44D30009C244 /* Sources */, 105 | FBBCBC3A1EFD44D30009C244 /* Frameworks */, 106 | FBBCBC3B1EFD44D30009C244 /* Resources */, 107 | ); 108 | buildRules = ( 109 | ); 110 | dependencies = ( 111 | ); 112 | name = ZXCodeCreater; 113 | productName = ZXCodeCreater; 114 | productReference = FBBCBC3D1EFD44D30009C244 /* ZXCodeCreater.app */; 115 | productType = "com.apple.product-type.application"; 116 | }; 117 | /* End PBXNativeTarget section */ 118 | 119 | /* Begin PBXProject section */ 120 | FBBCBC351EFD44D30009C244 /* Project object */ = { 121 | isa = PBXProject; 122 | attributes = { 123 | LastUpgradeCheck = 0720; 124 | ORGANIZATIONNAME = zx; 125 | TargetAttributes = { 126 | FBBCBC3C1EFD44D30009C244 = { 127 | CreatedOnToolsVersion = 7.2.1; 128 | }; 129 | }; 130 | }; 131 | buildConfigurationList = FBBCBC381EFD44D30009C244 /* Build configuration list for PBXProject "ZXCodeCreater" */; 132 | compatibilityVersion = "Xcode 3.2"; 133 | developmentRegion = English; 134 | hasScannedForEncodings = 0; 135 | knownRegions = ( 136 | en, 137 | Base, 138 | ); 139 | mainGroup = FBBCBC341EFD44D30009C244; 140 | productRefGroup = FBBCBC3E1EFD44D30009C244 /* Products */; 141 | projectDirPath = ""; 142 | projectRoot = ""; 143 | targets = ( 144 | FBBCBC3C1EFD44D30009C244 /* ZXCodeCreater */, 145 | ); 146 | }; 147 | /* End PBXProject section */ 148 | 149 | /* Begin PBXResourcesBuildPhase section */ 150 | FBBCBC3B1EFD44D30009C244 /* Resources */ = { 151 | isa = PBXResourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | FBBCBC4A1EFD44D30009C244 /* Assets.xcassets in Resources */, 155 | FBBCBC4D1EFD44D30009C244 /* Main.storyboard in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | FBBCBC391EFD44D30009C244 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | FBBCBC481EFD44D30009C244 /* ViewController.m in Sources */, 167 | FB0157401EFFA4E600D3AC5F /* FileHandle.m in Sources */, 168 | FBBCBC451EFD44D30009C244 /* main.m in Sources */, 169 | FBBCBC421EFD44D30009C244 /* AppDelegate.m in Sources */, 170 | FBBCBC571EFD49C00009C244 /* FileManager.m in Sources */, 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | /* End PBXSourcesBuildPhase section */ 175 | 176 | /* Begin PBXVariantGroup section */ 177 | FBBCBC4B1EFD44D30009C244 /* Main.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | FBBCBC4C1EFD44D30009C244 /* Base */, 181 | ); 182 | name = Main.storyboard; 183 | sourceTree = ""; 184 | }; 185 | /* End PBXVariantGroup section */ 186 | 187 | /* Begin XCBuildConfiguration section */ 188 | FBBCBC4F1EFD44D30009C244 /* Debug */ = { 189 | isa = XCBuildConfiguration; 190 | buildSettings = { 191 | ALWAYS_SEARCH_USER_PATHS = NO; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 199 | CLANG_WARN_EMPTY_BODY = YES; 200 | CLANG_WARN_ENUM_CONVERSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | CODE_SIGN_IDENTITY = "-"; 206 | COPY_PHASE_STRIP = NO; 207 | DEBUG_INFORMATION_FORMAT = dwarf; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | ENABLE_TESTABILITY = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu99; 211 | GCC_DYNAMIC_NO_PIC = NO; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 220 | GCC_WARN_UNDECLARED_SELECTOR = YES; 221 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 222 | GCC_WARN_UNUSED_FUNCTION = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | MACOSX_DEPLOYMENT_TARGET = 10.11; 225 | MTL_ENABLE_DEBUG_INFO = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = macosx; 228 | }; 229 | name = Debug; 230 | }; 231 | FBBCBC501EFD44D30009C244 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 236 | CLANG_CXX_LIBRARY = "libc++"; 237 | CLANG_ENABLE_MODULES = YES; 238 | CLANG_ENABLE_OBJC_ARC = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_EMPTY_BODY = YES; 243 | CLANG_WARN_ENUM_CONVERSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 246 | CLANG_WARN_UNREACHABLE_CODE = YES; 247 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 248 | CODE_SIGN_IDENTITY = "-"; 249 | COPY_PHASE_STRIP = NO; 250 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 251 | ENABLE_NS_ASSERTIONS = NO; 252 | ENABLE_STRICT_OBJC_MSGSEND = YES; 253 | GCC_C_LANGUAGE_STANDARD = gnu99; 254 | GCC_NO_COMMON_BLOCKS = YES; 255 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 256 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 257 | GCC_WARN_UNDECLARED_SELECTOR = YES; 258 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 259 | GCC_WARN_UNUSED_FUNCTION = YES; 260 | GCC_WARN_UNUSED_VARIABLE = YES; 261 | MACOSX_DEPLOYMENT_TARGET = 10.11; 262 | MTL_ENABLE_DEBUG_INFO = NO; 263 | SDKROOT = macosx; 264 | }; 265 | name = Release; 266 | }; 267 | FBBCBC521EFD44D30009C244 /* Debug */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 271 | COMBINE_HIDPI_IMAGES = YES; 272 | INFOPLIST_FILE = ZXCodeCreater/Info.plist; 273 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 274 | PRODUCT_BUNDLE_IDENTIFIER = com.zhengxu.ZXCodeCreater; 275 | PRODUCT_NAME = "$(TARGET_NAME)"; 276 | }; 277 | name = Debug; 278 | }; 279 | FBBCBC531EFD44D30009C244 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 283 | COMBINE_HIDPI_IMAGES = YES; 284 | INFOPLIST_FILE = ZXCodeCreater/Info.plist; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = com.zhengxu.ZXCodeCreater; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | }; 289 | name = Release; 290 | }; 291 | /* End XCBuildConfiguration section */ 292 | 293 | /* Begin XCConfigurationList section */ 294 | FBBCBC381EFD44D30009C244 /* Build configuration list for PBXProject "ZXCodeCreater" */ = { 295 | isa = XCConfigurationList; 296 | buildConfigurations = ( 297 | FBBCBC4F1EFD44D30009C244 /* Debug */, 298 | FBBCBC501EFD44D30009C244 /* Release */, 299 | ); 300 | defaultConfigurationIsVisible = 0; 301 | defaultConfigurationName = Release; 302 | }; 303 | FBBCBC511EFD44D30009C244 /* Build configuration list for PBXNativeTarget "ZXCodeCreater" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | FBBCBC521EFD44D30009C244 /* Debug */, 307 | FBBCBC531EFD44D30009C244 /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | /* End XCConfigurationList section */ 313 | }; 314 | rootObject = FBBCBC351EFD44D30009C244 /* Project object */; 315 | } 316 | -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/project.xcworkspace/xcuserdata/zx.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater.xcodeproj/project.xcworkspace/xcuserdata/zx.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/xcuserdata/zx.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/xcuserdata/zx.xcuserdatad/xcschemes/ZXCodeCreater.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ZXCodeCreater.xcodeproj/xcuserdata/zx.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ZXCodeCreater.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FBBCBC3C1EFD44D30009C244 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ZXCodeCreater/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/23. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ZXCodeCreater/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/23. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | // Insert code here to initialize your application 19 | } 20 | 21 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 22 | // Insert code here to tear down your application 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ZXCodeCreater/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "size" : "128x128", 25 | "idiom" : "mac", 26 | "filename" : "ZXCodeCreaterIcon.png", 27 | "scale" : "1x" 28 | }, 29 | { 30 | "size" : "128x128", 31 | "idiom" : "mac", 32 | "filename" : "ZXCodeCreaterIcon@2x.png", 33 | "scale" : "2x" 34 | }, 35 | { 36 | "idiom" : "mac", 37 | "size" : "256x256", 38 | "scale" : "1x" 39 | }, 40 | { 41 | "idiom" : "mac", 42 | "size" : "256x256", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "idiom" : "mac", 47 | "size" : "512x512", 48 | "scale" : "1x" 49 | }, 50 | { 51 | "idiom" : "mac", 52 | "size" : "512x512", 53 | "scale" : "2x" 54 | } 55 | ], 56 | "info" : { 57 | "version" : 1, 58 | "author" : "xcode" 59 | } 60 | } -------------------------------------------------------------------------------- /ZXCodeCreater/Assets.xcassets/AppIcon.appiconset/ZXCodeCreaterIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Assets.xcassets/AppIcon.appiconset/ZXCodeCreaterIcon.png -------------------------------------------------------------------------------- /ZXCodeCreater/Assets.xcassets/AppIcon.appiconset/ZXCodeCreaterIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Assets.xcassets/AppIcon.appiconset/ZXCodeCreaterIcon@2x.png -------------------------------------------------------------------------------- /ZXCodeCreater/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ZXCodeCreater/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | Default 513 | 514 | 515 | 516 | 517 | 518 | 519 | Left to Right 520 | 521 | 522 | 523 | 524 | 525 | 526 | Right to Left 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | Default 538 | 539 | 540 | 541 | 542 | 543 | 544 | Left to Right 545 | 546 | 547 | 548 | 549 | 550 | 551 | Right to Left 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | -------------------------------------------------------------------------------- /ZXCodeCreater/FileContent/ApiManager/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/FileContent/ApiManager/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/FileContent/Ctrler/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/FileContent/Ctrler/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/FileContent/Reformer/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/FileContent/Reformer/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/FileContent/View/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/FileContent/View/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2017年 zx. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/IntroductionDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/IntroductionDiagram.png -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/IntroductionDiagram.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/IntroductionDiagram.sketch -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/Original.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/Original.sketch -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/ZXCodeCreaterIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/ZXCodeCreaterIcon.png -------------------------------------------------------------------------------- /ZXCodeCreater/Resource/ZXCodeCreaterIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreater/Resource/ZXCodeCreaterIcon@2x.png -------------------------------------------------------------------------------- /ZXCodeCreater/Ulits/FileHandle.h: -------------------------------------------------------------------------------- 1 | // 2 | // FileHandle.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FileHandle : NSObject 12 | + (instancetype)shareInstance; 13 | - (void)clearFileContentWithFilePath:(NSString *)filePath; 14 | - (void)writeContentToFileWithFilePath:(NSString *)filePath content:(NSString *)content; 15 | @end 16 | -------------------------------------------------------------------------------- /ZXCodeCreater/Ulits/FileHandle.m: -------------------------------------------------------------------------------- 1 | // 2 | // FileHandle.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "FileHandle.h" 10 | @interface FileHandle() 11 | @property (nonatomic,strong) NSFileHandle *fileHandler; 12 | @end 13 | 14 | @implementation FileHandle 15 | + (instancetype)shareInstance 16 | { 17 | static FileHandle *shareInstance = nil; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | shareInstance = [[FileHandle alloc] init]; 21 | }); 22 | return shareInstance; 23 | } 24 | 25 | 26 | - (void)clearFileContentWithFilePath:(NSString *)filePath 27 | { 28 | 29 | self.fileHandler = [NSFileHandle fileHandleForWritingAtPath:filePath]; 30 | [self.fileHandler truncateFileAtOffset:0]; 31 | } 32 | 33 | - (void)writeContentToFileWithFilePath:(NSString *)filePath content:(NSString *)content 34 | { 35 | self.fileHandler = [NSFileHandle fileHandleForWritingAtPath:filePath]; 36 | [self.fileHandler writeData:[content dataUsingEncoding:NSUTF8StringEncoding]]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ZXCodeCreater/Ulits/FileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // FileManager.h 3 | // ESJsonFormatForMac 4 | // 5 | // Created by zx on 17/6/13. 6 | // Copyright © 2017年 ZX. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FileManager : NSObject 12 | + (FileManager *)sharedInstance; 13 | /**创建文件夹*/ 14 | - (void)createFolderAtPath:(NSString *)folder; 15 | /**创建文件*/ 16 | - (void)createFileAtPath:(NSString *)FilePath content:(NSString *)content; 17 | /**获取文件内容*/ 18 | - (NSString *)getStringWithContentsOfFilePath:(NSString *)filePath; 19 | /**根据目录遍历文件夹*/ 20 | - (NSArray *)getFilePathArrWithPath:(NSString *)dirPath; 21 | @end 22 | -------------------------------------------------------------------------------- /ZXCodeCreater/Ulits/FileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // FileManager.m 3 | // ESJsonFormatForMac 4 | // 5 | // Created by zx on 17/6/13. 6 | // Copyright © 2017年 ZX. All rights reserved. 7 | // 8 | 9 | #import "FileManager.h" 10 | @interface FileManager() 11 | @property (nonatomic,strong) NSFileManager *fileManager; 12 | @end 13 | 14 | 15 | @implementation FileManager 16 | 17 | + (FileManager *)sharedInstance 18 | { 19 | static FileManager *sharedInstance = nil; 20 | static dispatch_once_t predicate; 21 | dispatch_once(&predicate, ^{ 22 | sharedInstance = [[self alloc] init]; 23 | }); 24 | return sharedInstance; 25 | } 26 | - (void)createFileAtFilePath:(NSString *)filePath 27 | fileName:(NSString *)fileName 28 | hContent :(NSString *)hContent 29 | mContent :(NSString *)mContent 30 | 31 | { 32 | //创建.h文件 33 | [self createFileAtPath:[filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.h",fileName]] content:hContent]; 34 | if (![fileName containsString:@"Keys"]) { 35 | //创建.m文件 36 | [self createFileAtPath:[filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.m",fileName]] content:mContent]; 37 | } 38 | 39 | } 40 | 41 | - (void)createFolderAtPath:(NSString *)folder{ 42 | 43 | [self.fileManager createDirectoryAtPath:folder withIntermediateDirectories:YES attributes:nil error:nil]; 44 | } 45 | 46 | 47 | - (void)createFileAtPath:(NSString *)FilePath content:(NSString *)content{ 48 | 49 | 50 | [self.fileManager createFileAtPath:FilePath contents:[content dataUsingEncoding:NSUTF8StringEncoding] attributes:nil]; 51 | } 52 | 53 | - (NSString *)getStringWithContentsOfFilePath:(NSString *)filePath{ 54 | 55 | NSData *reader = [NSData dataWithContentsOfFile:filePath]; 56 | NSString *content = [[NSString alloc] initWithData:reader encoding:NSUTF8StringEncoding]; 57 | return content; 58 | 59 | } 60 | 61 | 62 | - (NSArray *)getFilePathArrWithPath:(NSString *)dirPath 63 | { 64 | 65 | NSFileManager *fileManager= [NSFileManager defaultManager]; 66 | NSMutableArray *fileArr = [NSMutableArray array]; 67 | NSDirectoryEnumerator *myDirectoryEnumerator; 68 | myDirectoryEnumerator=[fileManager enumeratorAtPath:dirPath]; 69 | //列举目录内容,可以遍历子目录 70 | NSLog(@"用enumeratorAtPath:显示目录%@的内容:",dirPath); 71 | 72 | while((dirPath=[myDirectoryEnumerator nextObject])!=nil) 73 | 74 | { 75 | [fileArr addObject:dirPath]; 76 | NSLog(@"%@",dirPath); 77 | 78 | } 79 | 80 | return [fileArr copy]; 81 | } 82 | 83 | 84 | 85 | 86 | - (NSFileManager *)fileManager 87 | { 88 | if (!_fileManager) { 89 | 90 | _fileManager = [NSFileManager defaultManager]; 91 | } 92 | return _fileManager; 93 | } 94 | @end 95 | -------------------------------------------------------------------------------- /ZXCodeCreater/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/23. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : NSViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ZXCodeCreater/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/23. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "FileManager.h" 11 | #import "FileHandle.h" 12 | 13 | 14 | 15 | #define UserDefaults [NSUserDefaults standardUserDefaults] 16 | NSString *const firstFolderPath = @"firstFolderPath"; 17 | NSString *const secondFolderPath = @"secondFolderPath"; 18 | NSString *const firstClassPrefix = @"firstClassPrefix"; 19 | NSString *const secondClassPrefix = @"secondClassPrefix"; 20 | @interface ViewController() 21 | 22 | 23 | @property (unsafe_unretained) IBOutlet NSTextView *firstModulePathTxv; 24 | @property (weak) IBOutlet NSTextField *firstModuleTxf; 25 | @property (weak) IBOutlet NSTextField *firstReplacedTxf; 26 | 27 | @property (unsafe_unretained) IBOutlet NSTextView *secondModulePathTxv; 28 | @property (weak) IBOutlet NSTextField *secondModuleTxf; 29 | @property (weak) IBOutlet NSTextField *secondReplacedTxf; 30 | 31 | 32 | @property (nonatomic,copy) NSString *firstFolderPathString; 33 | @property (nonatomic,copy) NSString *secondFolderPathString; 34 | 35 | @property (nonatomic,copy) NSString *moduleClassPrefix; 36 | @property (nonatomic,copy) NSString *targetClassPrefix; 37 | 38 | @end 39 | 40 | 41 | @implementation ViewController 42 | #pragma mark - Life Cycle 43 | - (void)viewDidLoad { 44 | [super viewDidLoad]; 45 | [self initData]; 46 | 47 | } 48 | 49 | - (void)initData 50 | { 51 | self.firstFolderPathString = [UserDefaults objectForKey:firstFolderPath]; 52 | self.secondFolderPathString = [UserDefaults objectForKey:secondFolderPath]; 53 | 54 | NSString *firstClassPrefixString = [UserDefaults objectForKey:firstClassPrefix]; 55 | NSString *secondClassPrefixString = [UserDefaults objectForKey:secondClassPrefix]; 56 | 57 | 58 | if (self.firstFolderPathString) { 59 | 60 | self.firstModulePathTxv.string = self.firstFolderPathString; 61 | } 62 | if (self.secondFolderPathString) { 63 | 64 | self.secondModulePathTxv.string = self.secondFolderPathString; 65 | } 66 | 67 | if (firstClassPrefixString) { 68 | 69 | self.firstModuleTxf.stringValue = firstClassPrefixString; 70 | } 71 | 72 | if (secondClassPrefixString) { 73 | 74 | self.secondModuleTxf.stringValue = secondClassPrefixString; 75 | } 76 | 77 | } 78 | 79 | 80 | - (IBAction)firstOpenBtnAction:(NSButton *)sender { 81 | 82 | [self openPanelWithSenderTag:sender.tag]; 83 | } 84 | - (IBAction)firstCreateBtnAction:(id)sender { 85 | 86 | self.firstFolderPathString = self.firstModulePathTxv.string; 87 | if (!self.firstModulePathTxv.string||[self.firstModulePathTxv.string isEqualToString:@""]) { 88 | 89 | [self showAlertWithMessage:@"Please select first module filePath "]; 90 | return; 91 | } 92 | 93 | if (!self.firstModuleTxf.stringValue||[self.firstModuleTxf.stringValue isEqualToString:@""]) { 94 | 95 | [self showAlertWithMessage:@"Please input first mlass prefix "]; 96 | return; 97 | } 98 | 99 | 100 | if (!self.firstReplacedTxf.stringValue||[self.firstReplacedTxf.stringValue isEqualToString:@""]) { 101 | 102 | [self showAlertWithMessage:@"Please input first target class prefix "]; 103 | return; 104 | } 105 | 106 | self.moduleClassPrefix = self.firstModuleTxf.stringValue; 107 | self.targetClassPrefix = self.firstReplacedTxf.stringValue; 108 | [self creatFolderAndFileAtModuleFilePath:self.firstFolderPathString]; 109 | [UserDefaults setObject:self.firstModuleTxf.stringValue forKey:firstClassPrefix]; 110 | } 111 | 112 | - (IBAction)secondOpenBtnAction:(NSButton *)sender { 113 | 114 | [self openPanelWithSenderTag:sender.tag]; 115 | } 116 | 117 | - (IBAction)secondCreateOpenBtnAction:(id)sender { 118 | 119 | 120 | self.secondFolderPathString = self.secondModulePathTxv.string; 121 | 122 | if (!self.secondModulePathTxv.string||[self.secondModulePathTxv.string isEqualToString:@""]) { 123 | 124 | [self showAlertWithMessage:@"Please select second module filePath "]; 125 | return; 126 | } 127 | 128 | if (!self.secondModuleTxf.stringValue||[self.secondModuleTxf.stringValue isEqualToString:@""]) { 129 | 130 | [self showAlertWithMessage:@"Please input second mlass prefix "]; 131 | return; 132 | } 133 | 134 | 135 | if (!self.secondReplacedTxf.stringValue||[self.secondReplacedTxf.stringValue isEqualToString:@""]) { 136 | 137 | [self showAlertWithMessage:@"Please input second target class prefix "]; 138 | return; 139 | } 140 | self.moduleClassPrefix = self.secondModuleTxf.stringValue; 141 | self.targetClassPrefix = self.secondReplacedTxf.stringValue; 142 | [self creatFolderAndFileAtModuleFilePath:self.secondFolderPathString]; 143 | [UserDefaults setObject:self.secondModuleTxf.stringValue forKey:secondClassPrefix]; 144 | } 145 | 146 | 147 | - (void)openPanelWithSenderTag:(NSUInteger)tag 148 | { 149 | NSOpenPanel *panel = [NSOpenPanel openPanel]; 150 | [panel setTitle:@"ZXCodeCreater"]; 151 | [panel setCanChooseDirectories:YES]; 152 | [panel setCanCreateDirectories:YES]; 153 | [panel setCanChooseFiles:NO]; 154 | if ([panel runModal] == NSModalResponseOK) { 155 | 156 | NSString *tempPathString = [[[panel URLs] objectAtIndex:0] relativePath]; 157 | if (tag==201) { 158 | 159 | self.firstFolderPathString = tempPathString; 160 | self.firstModulePathTxv.string = self.firstFolderPathString; 161 | [[NSUserDefaults standardUserDefaults] setValue:self.firstFolderPathString forKey:firstFolderPath]; 162 | }else{ 163 | self.secondFolderPathString = tempPathString; 164 | self.secondModulePathTxv.string = self.secondFolderPathString; 165 | [[NSUserDefaults standardUserDefaults] setValue:self.secondFolderPathString forKey:secondFolderPath]; 166 | } 167 | 168 | } 169 | 170 | } 171 | 172 | - (void)creatFolderAndFileAtModuleFilePath:(NSString *)filePath 173 | { 174 | //所有的文件以及文件夹子目录 175 | NSArray *filePathArr = [[FileManager sharedInstance] getFilePathArrWithPath:filePath]; 176 | for (NSString *subPath in filePathArr) { 177 | NSString * wholePath = [filePath stringByAppendingPathComponent:subPath]; 178 | //直接修改路径,然后根据路径新建文件夹及其文件,也就相当于修改文件及其文件夹名称; 179 | NSString *newWholePath = [wholePath stringByReplacingOccurrencesOfString:self.moduleClassPrefix withString:self.targetClassPrefix]; 180 | //忽略隐藏文件 181 | if ([subPath containsString:@".DS_Store"]) { 182 | 183 | continue; 184 | } 185 | //文件夹路径;如果是文件夹的话,就创建文件夹(如果后缀是.h或者.m的话,那么就是文件,否则是文件夹) 186 | if (!([subPath containsString:@".h"]||[subPath containsString:@".m"])) { 187 | 188 | [[FileManager sharedInstance] createFolderAtPath:newWholePath]; 189 | continue; 190 | } 191 | NSString *str = [[FileManager sharedInstance] getStringWithContentsOfFilePath:wholePath]; 192 | //将文件中的字段替换成目标字段 193 | NSString *replacedStr = [str stringByReplacingOccurrencesOfString:self.moduleClassPrefix withString:self.targetClassPrefix]; 194 | //修改文件顶部注释的模板文件中的日期; 195 | NSString *stringAfterReplaceDate = [self replaceModuleDateWithNowDate:[self getNowDateStr] nowYear:[self getNowYearStr] moduleStr:replacedStr]; 196 | //创建文件 197 | [[FileManager sharedInstance] createFileAtPath:newWholePath content:stringAfterReplaceDate]; 198 | } 199 | [[NSWorkspace sharedWorkspace] openFile:filePath]; 200 | } 201 | 202 | 203 | 204 | #pragma mark - ReplaceDate 205 | - (NSString *)replaceModuleDateWithNowDate:(NSString *)nowDate nowYear:(NSString *)nowYear moduleStr:(NSString *)moduleStr{ 206 | 207 | NSMutableString *searchText = [NSMutableString stringWithFormat:@"%@",moduleStr]; 208 | NSError *error = NULL; 209 | //匹配17/06/25 210 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}" options:NSRegularExpressionCaseInsensitive error:&error]; 211 | //匹配2017年; 212 | NSRegularExpression *regexT = [NSRegularExpression regularExpressionWithPattern:@"[0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1}[\u4e00-\u9fa5]" options:NSRegularExpressionCaseInsensitive error:&error]; 213 | [regex replaceMatchesInString:searchText options:0 range:NSMakeRange(0, searchText.length) withTemplate:nowDate]; 214 | [regexT replaceMatchesInString:searchText options:0 range:NSMakeRange(0, searchText.length) withTemplate:nowYear]; 215 | return searchText; 216 | } 217 | 218 | - (NSString *)getNowDateStr{ 219 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 220 | formatter.dateFormat = @"yy/MM/dd"; 221 | return [formatter stringFromDate:[NSDate date]]; 222 | } 223 | 224 | - (NSString *)getNowYearStr{ 225 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 226 | formatter.dateFormat = @"yyyy"; 227 | 228 | NSString *nowYear = [NSString stringWithFormat:@"%@年",[formatter stringFromDate:[NSDate date]]]; 229 | 230 | return nowYear; 231 | } 232 | 233 | 234 | - (void)showAlertWithMessage:(NSString *)message{ 235 | 236 | NSAlert *alert = [[NSAlert alloc] init]; 237 | [alert setMessageText:message]; 238 | [alert runModal]; 239 | } 240 | 241 | @end 242 | -------------------------------------------------------------------------------- /ZXCodeCreater/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/23. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreaterTestModule/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czhen09/ZXCodeCreater/6fdcaf01b081bd8cb02179847a9d18db671025d3/ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/.DS_Store -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/ZXCodeCreaterTestView/ZXCodeCreaterTestView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterTestView.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/26. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZXCodeCreaterTestView : NSView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/ZXCodeCreaterTestView/ZXCodeCreaterTestView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterTestView.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/26. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "ZXCodeCreaterTestView.h" 10 | 11 | @implementation ZXCodeCreaterTestView 12 | 13 | - (void)drawRect:(NSRect)dirtyRect { 14 | [super drawRect:dirtyRect]; 15 | 16 | // Drawing code here. 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/ZXCodeCreaterTestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterViewController.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ZXCodeCreaterTestManager; 11 | @interface ZXCodeCreaterTestViewController : NSViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestCtrler/ZXCodeCreaterTestViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterViewController.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "ZXCodeCreaterTestViewController.h" 10 | #import "ZXCodeCreaterTestManager.h" 11 | @interface ZXCodeCreaterTestViewController () 12 | 13 | @end 14 | 15 | @implementation ZXCodeCreaterTestViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do view setup here. 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestManager/ZXCodeCreaterTestManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterManager.h 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ZXCodeCreaterTestViewController; 11 | @interface ZXCodeCreaterTestManager : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ZXCodeCreaterTestModule/ZXCodeCreaterTestManager/ZXCodeCreaterTestManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZXCodeCreaterManager.m 3 | // ZXCodeCreater 4 | // 5 | // Created by zx on 17/6/25. 6 | // Copyright © 2017年 zx. All rights reserved. 7 | // 8 | 9 | #import "ZXCodeCreaterTestManager.h" 10 | #import "ZXCodeCreaterTestViewController.h" 11 | @implementation ZXCodeCreaterTestManager 12 | 13 | @end 14 | --------------------------------------------------------------------------------