Skip to content

Commit 48a8c3a

Browse files
author
李杰
committed
fix swift Notification #47
1 parent d08a4b1 commit 48a8c3a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

JJException/Source/ARC/NSNotificationCenter+ClearNotification.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ + (void)jj_swizzleNSNotificationCenter{
2323

2424
- (void)processAddObserver:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject swizzleInfo:(JJSwizzleObject*)swizzleInfo{
2525

26-
if (observer) {
26+
if (!observer) {
27+
return;
28+
}
29+
30+
if ([observer isKindOfClass:NSObject.class]) {
2731
__unsafe_unretained typeof(observer) unsafeObject = observer;
2832
[observer jj_deallocBlock:^{
2933
[[NSNotificationCenter defaultCenter] removeObserver:unsafeObject];
3034
}];
31-
void(*originIMP)(__unsafe_unretained id,SEL,id,SEL,NSString*,id);
32-
originIMP = (__typeof(originIMP))[swizzleInfo getOriginalImplementation];
35+
}
36+
37+
void(*originIMP)(__unsafe_unretained id,SEL,id,SEL,NSString*,id);
38+
originIMP = (__typeof(originIMP))[swizzleInfo getOriginalImplementation];
39+
if (originIMP != NULL) {
3340
originIMP(self,swizzleInfo.selector,observer,aSelector,aName,anObject);
3441
}
3542
}

0 commit comments

Comments
 (0)