// // NSDictionary+Safe.m // MSYOUPAI // // Created by YoMi on 2023/11/7. // #import "NSDictionary+Safe.h" #import "NSObject+ImpChangeTool.h" #import @implementation NSDictionary (Safe) + (void)load{ [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