Why would class_getInstanceMethod return nil?

I am running into a problem when I attemp to call class_getInstanceMethod on a selected method in the parent class of a category I am writting.


When I try to set the original method implementation using class_getInstanceMethod, it is returning 'nil'.


When I try to set the Method implementation on a method in my category, it is not having any issues. Here is an example of what I am trying to do;


// Thirdparty Library class in a CocoaPod
// ThirdPartyLogger.h
@interface ThirdPartyLogger : NSObject
-(instancetype)init;
-(void)deleteLogFiles;
@end

//ThirdPartyLogger.m
#import "ThirdPartyLogger.h"
@implementation
- (instancetype)init {
   [self super];
     return self;
}

-(void)deleteLogFiles {
     // original implementation
}
@end

// Here is my code
// ThirdPartyLogger+David.h
#import "ThirdPartyLogger.h"

@interface ThirdPartyLogger (David)
- (void)deleteLogFilesDavid;
@end

// ThirdPartyLogger+David.m
#import "ThirdPartyLogger+David.h"

@implementation

-(void)deleteLogFilesDavid {
     // new implementation
}

+(void)load {
     original = class_getInstanceMethod(self, @selector(deleteLogFiles)); // returns nil  :-(
     swizzled = class_getInstanceMethod(self, @selector(deleteLogFilesDavid)); // returns a valid method implementation
     method_exchangeImplementations(original, swizzled);
}
@end


Any ideas?

Should not it be like below?
Code Block obj-c
original = class_getInstanceMethod([self class], @selector(deleteLogFiles));
swizzled = class_getInstanceMethod([self class], @selector(deleteLogFilesDavid));


Why would class_getInstanceMethod return nil?
 
 
Q