Giter VIP home page Giter VIP logo

lcxcrashextension's Introduction

LCXCrashExtension

LCXCashExtension is the last defender of your code, protect your code to crash.

like this,will no crash:

    NSMutableArray *marray = [NSMutableArray new];
    [marray objectAtIndex:1];
    [marray addObject:nil];
    [marray insertObject:nil atIndex:0];
    [marray removeObjectAtIndex:2];
    [marray replaceObjectAtIndex:3 withObject:@"1"];
    [marray replaceObjectAtIndex:1 withObject:nil];
     NSMutableDictionary *tempDict = [NSMutableDictionary new];
    [tempDict setObject:nil forKey:@"1"];
    [tempDict removeObjectForKey:@"2"];
    [tempDict removeObjectForKey:nil];
    NSString *good = [[NSString alloc]initWithString:nil];
    NSString *good2 = [NSString stringWithString:nil];

    NSString *tempContstStr = @"123123";
    NSString *tempContstStr1 = [tempContstStr substringFromIndex:10];
    NSString *tempContstStr2 = [tempContstStr substringToIndex:10];
    NSString *tempContstStr3 = [tempContstStr substringWithRange:NSMakeRange(6, 1)];

    NSString *tempPointStr = [[NSString alloc]initWithFormat:@"123%@",@"123"];
    NSString *tempPointStr1 = [tempPointStr substringFromIndex:10];
    NSString *tempPointStr2 = [tempPointStr substringToIndex:10];
    NSString *tempPointStr3 = [tempPointStr substringWithRange:NSMakeRange(6, 1)];

    NSMutableString *tempCFStr = [[NSMutableString alloc]initWithFormat:@"123%@",@"123"];
    NSString *tempCFStr1 = [tempCFStr substringFromIndex:10];
    NSString *tempCFStr2 = [tempCFStr substringToIndex:10];
    NSString *tempCFStr3 = [tempCFStr substringWithRange:NSMakeRange(6, 1)];
   NSArray *arrayRang = [[NSArray alloc]initWithObjects:@"1", nil];
  [arrayRang objectAtIndex:6];

  NSMutableDictionary *tempDict = [NSMutableDictionary new];
  [tempDict setObject:nil forKey:@"1"];

  NSArray *array = [NSArray new];
  [array objectAtIndex:0];
  NSDictionary *dict = (NSDictionary *)array;
  NSLog(@"%@",dict.allKeys);
    NSMutableDictionary *tempDict = [NSMutableDictionary new];
    [tempDict setObject:nil forKey:@"1"];
    [tempDict removeObjectForKey:@"2"];
    [tempDict removeObjectForKey:nil];
    [self addObserver:self forKeyPath:nil options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
    [self removeObserver:nil forKeyPath:@"kvc"];
    [self.navigationController pushViewController:self animated:YES];

recommend this:

  NSString *stringValue = (NSString *)[NSDictionary new];
  if ([stringValue isValueString]) {
    NSLog(@"success");
  }else{
    NSLog(@"fail");
  }

crash warning:

    for (int i = 0; i < 10000; i++){
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                self.model = [TestModel new];
        });
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                self.model = [TestModel new];
        });
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                self.model = [TestModel new];
        });
    }

此demo为常见crash汇总与基本防护,详见demo

基本原理:http://www.jianshu.com/p/2b2997749d2d

lcxcrashextension's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

2797873866

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.