IOS 中runtime 不可变数组__NSArray0 和__NSArrayI
IOS 中runtime 不可变数组__NSArray0 和__NSArrayI 大家可能都遇到过项目中不可变数组避免数组越界的处理:runtime,然而有时候并不能解决所有的问题,因为类簇不一样 #import "NSArray+Security.h" #import "NSObject+Swizzling.h" @implementation NSArray (Security) + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [objc_getClass("__NSArray0") methodSwizzlingWithOriginalSelector:@selector(objectAtIndex:) bySwizzledSelector:@selector(safeObjectAtIndex:)]; }); } - (id)safeObjectAtIndex:(NSUInteger)index { if (self.count ...


