With the swizzling "helper" methods included in ConciseKit , you actually invoke the default implementation ... strangely enough ... by invoking your SWIZZLED implementation ..
You set it to + (void) load by calling + (BOOL)swizzleMethod:(SEL)originalSelector with:(SEL)anotherSelector in:(Class)klass; , i.e.
[$ swizzleMethod:@selector(oldTired:) with:@selector(swizzledHotness:) in:self.class];
and then in the swizzled method .. suppose it returns -(id) .. you can do your evil or whatever reason that you first launched ... and then instead of returning the object or self , or something else.
return [self swizzledHotness:yourSwizzledMethodsArgument];
As explained here ...
In this method, it looks like we are calling the same method again, calling infinite recursion. But by the time this line is reached, both methods have been replaced. Therefore, when we call swizzled_synchronize, we actually call the original method.
It feels and looks weird, but .. it works. This allows you to add endless embellishments to existing methods and still βcall superβ (actually βmeβ) and take advantage of the original handiwork method ... even without access to the original source.
Alex Gray Apr 10 '13 at 16:12 2013-04-10 16:12
source share