eleme / Stinger

Stinger is a high-efficiency library with great compatibility, for aop in Objective-C, using libffi instead of Objective-C message forwarding. It is 20+ times faster than the Aspects, from message-sending to Aspect-oriented code ends.
MIT License
996 stars 127 forks source link

[CHG]增加防护代码,避免只hook特定对象并未hook该对象类可能造成的crash #2

Closed chenzhengxu closed 5 years ago

chenzhengxu commented 5 years ago

在测试工程中只保留以下hook方法

- (void)viewDidLoad {
  [super viewDidLoad];
  // hook for specific instance
  [self st_hookInstanceMethod:@selector(print3:) option:STOptionAfter usingIdentifier:@"hook_print3_after1" withBlock:^(id<StingerParams> params, NSString *s) {
    NSLog(@"---specific instance-self after print3: %@", s);
  }];
}

之后调用@selector(print3:)方法会引发crash