Skip to content

Instantly share code, notes, and snippets.

@serluca
Created February 26, 2015 10:18
Show Gist options
  • Save serluca/e4f6a47ffbc19fccc63e to your computer and use it in GitHub Desktop.
Save serluca/e4f6a47ffbc19fccc63e to your computer and use it in GitHub Desktop.
@implementation NSBundle (MYBundle)
+ (instancetype)MYBundle{
NSBundle *mainBundle = [NSBundle mainBundle];
NSURL *bundleUrl = [mainBundle URLForResource:@"MyBundle" withExtension:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithURL:bundleUrl];
return bundle;
}
+ (UIImage*)imageNamed:(NSString*)name{
UIImage *image;
image = [UIImage imageNamed:[NSString stringWithFormat:@"MyBundle.bundle/%@",name]];
if (image) {
return image;
}
image = [UIImage imageWithContentsOfFile:[[[NSBundle MYBundle] resourcePath] stringByAppendingPathComponent:name]];
return image;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment