Giter Club home page Giter Club logo

chcrash's Introduction

##CHCrash

  • 用一种超级简单的方式去防止Label的text被赋空值时导致程序崩溃。

##场景

  • ios的小伙伴们做项目的时候常常会遇到这样一种情况,就是后台返回数据,有时候莫名其面的返回了一个null值过来,然后我们解析的时候如果没有判断你的话,程序就会“崩”的一声,接着老板各种叽叽歪歪,然后就没有然后了。后台说是我们责任,我们又觉得是后台的责任。如果我们每一个都判断是否为null的话,工作量简直大得可怕啊!!!这个小框架就是为了解决这个问题而生的。
  • 数组越界的情况同样会导致程序崩溃,上线后程序有崩溃的情况是很恐怖的,至少老板发起火来。。集成这个框架,同样能避免数组越界导致的崩溃。同时log里会提示有数组越界的情况。

##如何使用CHCrash

  • 把demo中的CHCrash文件夹拖入项目中就可以了哦,不需要任何额外的配置。之后代码中所有label怎么赋予空值都不会导致崩溃了,数组越界则元素返回为nil,同时log里会有提示。

##说明

  • 框架产生的log只会在debug版出现,release版本没有log。
  • 如果你的项目恰好有这种情况,在给label赋值前需要大量判断字符是否为空的地方,这个框架恰好是为你量身制作哈!!
  • 项目中使用了运行时机制,在修改label的setText方法,对即将赋值的数据进行了判断,如果是不合法的数据,将不会对label的text进行赋值。
  • 数组防越界也是同理。
  • 欢迎fork,欢迎吐槽。
  • 鄙人qq:1013124327

chcrash's People

Contributors

stccon 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.