利用runtim method swizzle 对Objective-C中常用集合等类型进行crash防护,目前支持:
- NSArray/NSMutableArray
- NSDictionary/NSMutableArray
- NSSet/NSMutableSet
- NSString/NSMutableString
id obj = nil;
id value = nil;
NSDictionary *dict = @{@"anObject" : obj,
@"helloString" : @"Hello, World!",
@"magicNumber" : @42,
@"aValue" : value};
NSLog(@"dict:%@", dict);
/*
dict:{
aValue = "<null>";
anObject = "<null>";
helloString = "Hello, World!";
magicNumber = 42;
}
*/
DMSafeKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DMSafeKit'
liumenghua, [email protected]
DMSafeKit is available under the MIT license. See the LICENSE file for more info.