NSObjectSafe icon indicating copy to clipboard operation
NSObjectSafe copied to clipboard

Swizzle commonly used function of Foundation container to prevent nil crash

Results 21 NSObjectSafe issues
Sort by recently updated
recently updated
newest added

有没有具体的使用方法啊??

Cannot create __weak reference in file using manual reference counting

NSCache进行swizzing交换时,无需判断key为nil的情况,因为setObject:forKey方法里key不遵循NSCoping协议,而且通过本地测试(我用的iOS13)测试,当key为nil时,执行上述set方法不会crash,仍然可以继续执行

你好,我想在debug模式下生效,怎么使用?

Scene: UIActivityViewController *shareVC = [[UIActivityViewController alloc]initWithActivityItems:@[self.debugText.string] applicationActivities:nil]; [self presentViewController:shareVC animated:YES completion:nil]; Crash: crash at NSCache(safe) hookSetObject:forKey: ,because input an nil key, but when I don't use NSObjectSafe , it doesn't...

``` + (void)swizzleClassMethod:(SEL)origSelector withMethod:(SEL)newSelector { Class cls = [self class]; Method originalMethod = class_getClassMethod(cls, origSelector); Method swizzledMethod = class_getClassMethod(cls, newSelector); Class metacls = objc_getMetaClass(NSStringFromClass(cls).UTF8String); if (class_addMethod(metacls, origSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)) )...