Code Monkey home page Code Monkey logo

zxcodecreater's Introduction

CodeCreater

背景:

  1. 写代码的时候,可能经常会遇到多个模块中基础内容都是想似的,例如,你可能很多文件中都会懒加载一个UITableView实例对象,遵守UITableViewDelegate、UITableViewDataSource协议并实现方法,或者你在每一个类中都要写一个方法用来统一管理UI,用一个方法统一用来管理Layout,或者各种#pragma mark - ####;
  2. 类似的东西,处理大概如下:
    1).没有抽离过公用代码,用的时候重新敲一遍吧;
    2).没有抽离过公用代码,用的时候把以前的复制过来,多余的删掉吧;
    3).抽离过公用代码,用的时候直接复制修改类名拖过来就好啦;
    4).抽离过公用代码,用脚本生成需要的文件;
  3. 于是乎,我让它进化到了第五种:利用NSFileManager相关知识,封以MacOS外壳;能够通过通用模板生成目标文件夹及文件;

思路

其实在我最开始打算写这个小工具的时候,我是创建了很多个类的,准备一个一个的类用字符串拼接而成,并且当时想的可能写出来也不会适合大众模板,只会死死的停留在一个模板上;

之后突然发现,所谓的快速生成代码,对比之前的文件,改变的仅仅就是类名,文件名;然后就建立了模板,直接遍历模板中的文件夹及其文件,将模板中原来的字段替换成新字段就行了;

代码也很简单,想知其所以然的可以去看看;

贴金

  1. 快速生成所需文件夹及其文件代码,节省时间,提升开发效率;
  2. 一个模子刻出来的东西,风格统一;

一图概全

image

结语

  1. 使用之前,你们得为自己准备一份通用模板;
    如果暂时没有,可以通过文件目录下的ZXCodeCreaterTestModule文件夹进行测试;
  2. dmg软件包在Application目录下;
  3. 让CodeCreater去接受你们的考验吧!
  4. 使用愉快,谢谢star!
  5. 简书

zxcodecreater's People

Contributors

czhen09 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.