FAQ Database Discussion Community

Swizzling - Undo method selector swizzling in Objective-C iOS

We're making use of Swizzling in Objective-C. For convenience we're using CoconutKit's helper methods to achieve this: HLSSwizzleSelectorWithBlock_Begin([TMObjectCache class], @selector(objectForKey:)) ^(TMObjectCache *self, NSString *key) { key = nil; return ((id (*)(id, SEL, NSString*))_imp)(self, _cmd, key); } HLSSwizzleSelectorWithBlock_End; We'd like to however also un-swizzle this method after some point in the...

ISA swizzling and calls to `super`

Assume the following class hierarchy. Class A is publicly declared: @interface A : NSObject + (A)createInstance; - (void)a; @end Class _B is a private subclass of A: @interface _B : A - (void)a; - (void)b; @end Assume objects of class A should only be created using the factory method createInstance,...