直接引入工程项目里面就可以生效,无需添加import
pod 'DYSafeObject', '~> 0.1.1'
防止数组里面对象为nil的情况、数组越界产生的崩溃
NSString *s1 = nil;
NSArray *array = @[s1,@"a",@"v",@"c",@"d",@"f",@"s",@"v",@"g"];
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithArray:array];
NSLog(@"数组 Test--array:%@ mutableArray:%@",array[20],mutableArray[20]);
NSLog(@"数组 Test--array:%@ mutableArray:%@",[array objectAtIndex:20],mutableArray[20]);
NSLog(@"数组 Test--array%@",array);
NSString *key = nil;
NSString *str = nil;
NSDictionary *dict = @{key:str};
NSArray *dArray = @[str];
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
mutableDict[@"key"] = str;
NSLog(@"字典 Test--dict:%@",dict);
NSLog(@"字典 Test--dArray:%@",dArray);
NSLog(@"字典 Test--mutableDict:%@ key:%@",mutableDict,mutableDict[@"key"]);
NSMutableString *string = [[NSMutableString alloc] initWithFormat:@"世界因我而精彩"];
NSLog(@"字符串 Test--%@",[string substringFromIndex:50]);
NSDictionary *dic2 = @{@"key":[NSNull null]};
NSLog(@"dic2==%@",dic2);
[dic2[@"key"] UTF8String];