steipete / Aspects

Delightful, simple library for aspect oriented programming in Objective-C and Swift.
https://twitter.com/steipete
MIT License
8.4k stars 1.26k forks source link

Crash when handle notification in block #38

Open muyexi opened 9 years ago

muyexi commented 9 years ago

I want to add notification to all view using aspects, it crash wtih error "EXC_BAD_ACCESS" when receive notification

    [UIView aspect_hookSelector:@selector(initWithFrame:)
                     withOptions:AspectPositionAfter
                      usingBlock:^(id<AspectInfo> aspectInfo){
                          [[NSNotificationCenter defaultCenter] addObserverForName:HGDidUpdateViewModeNotification object:nil queue:nil usingBlock:^(NSNotification *note){
                              //Crash
                              if ([[aspectInfo instance] respondsToSelector:@selector(switchViewMode)]){

                              }
                          }];
ekingo commented 8 years ago

perhaps the aspected UIView was dealloc or reinit.

steipete commented 8 years ago

How does the crash look like when you run this with zombies enabled?