Skip to content

Instantly share code, notes, and snippets.

@gekitz
Created September 11, 2012 11:46
Show Gist options
  • Save gekitz/3697816 to your computer and use it in GitHub Desktop.
Save gekitz/3697816 to your computer and use it in GitHub Desktop.
Sample Method Swizzle
+ (void)initialize
{
NSError *error = nil;
[[self class] jr_swizzleClassMethod:@selector(imageNamed:) withClassMethod:@selector(gk_imageNamed:) error:&error];
}
+ (UIImage *)gk_imageNamed:(NSString *)str
{
UIImage *image = [UIImage gk_imageNamed:str];
if (!image && [str rangeOfString:@".jpg"].location == NSNotFound) {
image = [UIImage gk_imageNamed:[NSString stringWithFormat:@"%@.jpg",str]];
}
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment