@@ -70,28 +70,50 @@ static id InstrumentSurrogateDelegate(id self, id delegate, SEL originalSelector
70
70
SEL swizzledSelector, IMP selfImplementation,
71
71
IMP delegateImplementation);
72
72
73
+ /* *
74
+ * Animation did start selector for the animation delegate.
75
+ */
76
+ static SEL gAnimationDidStartSelector ;
77
+ /* *
78
+ * Swizzled animation did start selector for the animation delegate.
79
+ */
80
+ static SEL gSwizzledAnimationDidStartSelector ;
81
+ /* *
82
+ * Animation did stop selector for the animation delegate.
83
+ */
84
+ static SEL gAnimationDidStopSelector ;
85
+ /* *
86
+ * Swizzled animation did stop selector for the animation delegate.
87
+ */
88
+ static SEL gSwizzledAnimationDidStopSelector ;
89
+
73
90
@implementation GREYCAAnimationDelegate
74
91
92
+ + (void )initialize {
93
+ if (self == [GREYCAAnimationDelegate self ]) {
94
+ gAnimationDidStartSelector = @selector (animationDidStart: );
95
+ gSwizzledAnimationDidStartSelector = @selector (greyswizzled_animationDidStart: );
96
+ gAnimationDidStopSelector = @selector (animationDidStop:finished: );
97
+ gSwizzledAnimationDidStopSelector = @selector (greyswizzled_animationDidStop:finished: );
98
+ }
99
+ }
100
+
75
101
+ (id )surrogateDelegateForDelegate : (id )delegate {
76
102
id outDelegate;
77
103
if (!delegate) {
78
104
// If the delegate is nil then create and return a new delegate.
79
105
outDelegate = [[self alloc ] initInternal ];
80
106
} else {
81
- SEL animationDidStartSEL = @selector (animationDidStart: );
82
- SEL greyAnimationDidStartSEL = @selector (greyswizzled_animationDidStart: );
83
- SEL animationDidStopSEL = @selector (animationDidStop:finished: );
84
- SEL greyAnimationDidStopSEL = @selector (greyswizzled_animationDidStop:finished: );
85
- IMP animationDidStartInstance = [self instanceMethodForSelector: animationDidStartSEL];
86
- IMP delegateAnimationDidStartInstance = [delegate methodForSelector: animationDidStartSEL];
87
- IMP animationDidStopInstance = [self instanceMethodForSelector: animationDidStopSEL];
88
- IMP delegateAnimationDidStopInstance = [delegate methodForSelector: animationDidStopSEL];
89
- outDelegate =
90
- InstrumentSurrogateDelegate (self, delegate, animationDidStartSEL, greyAnimationDidStartSEL,
91
- animationDidStartInstance, delegateAnimationDidStartInstance);
92
- outDelegate =
93
- InstrumentSurrogateDelegate (self, outDelegate, animationDidStopSEL, greyAnimationDidStopSEL,
94
- animationDidStopInstance, delegateAnimationDidStopInstance);
107
+ IMP animationDidStartInstance = [self instanceMethodForSelector: gAnimationDidStartSelector ];
108
+ IMP delegateAnimationDidStartInstance = [delegate methodForSelector: gAnimationDidStartSelector ];
109
+ IMP animationDidStopInstance = [self instanceMethodForSelector: gAnimationDidStopSelector ];
110
+ IMP delegateAnimationDidStopInstance = [delegate methodForSelector: gAnimationDidStopSelector ];
111
+ outDelegate = InstrumentSurrogateDelegate (
112
+ self, delegate, gAnimationDidStartSelector , gSwizzledAnimationDidStartSelector ,
113
+ animationDidStartInstance, delegateAnimationDidStartInstance);
114
+ outDelegate = InstrumentSurrogateDelegate (
115
+ self, outDelegate, gAnimationDidStopSelector , gSwizzledAnimationDidStopSelector ,
116
+ animationDidStopInstance, delegateAnimationDidStopInstance);
95
117
}
96
118
return outDelegate;
97
119
}
0 commit comments