File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1010#import " include/ObjcDelegateProxy.h"
1111#import < objc/runtime.h>
1212
13- static NSSet <NSValue *> *selectors;
13+ #define OBJECT_VALUE (object ) [NSValue valueWithNonretainedObject: (object)]
14+
15+ static NSMutableDictionary <NSValue *, NSSet <NSValue *> *> *allSelectors;
1416
1517@implementation ObjcDelegateProxy
1618
1719- (NSSet *)selectors {
18- return selectors ;
20+ return allSelectors[ OBJECT_VALUE ( self .class)] ;
1921}
2022
2123+ (void )initialize
2224{
2325 @synchronized (ObjcDelegateProxy.class ) {
24- selectors = [self selectorsOfClass: self
26+ if (!allSelectors) {
27+ allSelectors = [NSMutableDictionary new ];
28+ }
29+ allSelectors[OBJECT_VALUE (self )] = [self selectorsOfClass: self
2530 withEncodedReturnType: [NSString stringWithFormat: @" %s " , @encode (void )]];
2631 }
2732}
@@ -31,7 +36,7 @@ - (BOOL)respondsToSelector:(SEL _Nonnull)aSelector {
3136}
3237
3338- (BOOL )canRespondToSelector : (SEL _Nonnull)selector {
34- for (id current in selectors ) {
39+ for (id current in allSelectors[ OBJECT_VALUE ( self .class)] ) {
3540 if (selector == (SEL ) [current pointerValue ]) {
3641 return true ;
3742 }
You can’t perform that action at this time.
0 commit comments