JJException icon indicating copy to clipboard operation
JJException copied to clipboard

NSMutableDictionary赋值野指针闪退

Open ZHDeveloper opened this issue 2 years ago • 3 comments

Describe the bug A clear and concise description of what the bug is.

NSMutableDictionary赋值野指针闪退

To Reproduce Steps to reproduce the behavior:

NSMutableDictionary *dict = [NSMutableDictionary dictionary];

__unsafe_unretained UIView *testObj = [[UIView alloc] init];
NSLog(@"testObj 指针指向的地址:%p 指针本身的地址:%p", testObj, &testObj);

dict[@"8888"] = testObj;
截屏2022-07-25 下午4 01 07

Please complete the following information

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Version [e.g. 22]

ZHDeveloper avatar Jul 25 '22 08:07 ZHDeveloper

正常使用API也有这种问题吧,这种问题不是JJException的范畴

jezzmemo avatar Jul 25 '22 15:07 jezzmemo

这种闪退能避免吗?

ZHDeveloper avatar Jul 26 '22 02:07 ZHDeveloper

OC技术上是可行的,大概原理,先要定位是哪里野指针了,然后将野指针的对象dealloc置换,不让它真正释放,到Swift就很难了

jezzmemo avatar Jul 26 '22 03:07 jezzmemo