Created
September 11, 2012 11:46
-
-
Save gekitz/3697816 to your computer and use it in GitHub Desktop.
Sample Method Swizzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (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