Authored by Justin R. Miller

allow for generic bundle resource retrieval

... ... @@ -167,6 +167,7 @@ typedef enum : NSUInteger {
- (void)setFrame:(CGRect)frame;
+ (UIImage *)resourceImageNamed:(NSString *)imageName;
+ (NSString *)pathForBundleResourceNamed:(NSString *)name ofType:(NSString *)extension;
#pragma mark - Movement
... ...
... ... @@ -405,16 +405,20 @@
+ (UIImage *)resourceImageNamed:(NSString *)imageName
{
NSAssert([[NSBundle mainBundle] pathForResource:@"MapBox" ofType:@"bundle"], @"Resource bundle not found in application.");
if ( ! [[imageName pathExtension] length])
imageName = [imageName stringByAppendingString:@".png"];
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"MapBox" ofType:@"bundle"];
return [UIImage imageWithContentsOfFile:[[self class] pathForBundleResourceNamed:imageName ofType:nil]];
}
+ (NSString *)pathForBundleResourceNamed:(NSString *)name ofType:(NSString *)extension
{
NSAssert([[NSBundle mainBundle] pathForResource:@"MapBox" ofType:@"bundle"], @"Resource bundle not found in application.");
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"MapBox" ofType:@"bundle"];
NSBundle *resourcesBundle = [NSBundle bundleWithPath:bundlePath];
NSString *imagePath = [resourcesBundle pathForResource:imageName ofType:nil];
return [UIImage imageWithContentsOfFile:imagePath];
return [resourcesBundle pathForResource:name ofType:extension];
}
- (void)dealloc
... ...