// // NSDictionary+TBXSafe.m // assemble // // Created by apple on 2020/11/2. // Copyright © 2020 kingsunsoft. All rights reserved. // #import "NSDictionary+TBXSafe.h" #import #import "NSObject+ImpChange.h" @implementation NSDictionary (TBXSafe) + (void)load{ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [self SwizzlingMethod:@"initWithObjects:forKeys:count:" systemClassString:@"__NSPlaceholderDictionary" toSafeMethodString:@"initWithObjects_st:forKeys:count:" targetClassString:@"NSDictionary"]; }); } -(instancetype)initWithObjects_st:(id *)objects forKeys:(id *)keys count:(NSUInteger)count { NSUInteger rightCount = 0; for (NSUInteger i = 0; i < count; i++) { if (!(keys[i] && objects[i])) { break; }else{ rightCount++; } } self = [self initWithObjects_st:objects forKeys:keys count:rightCount]; return self; } @end