All this is redundant if you are just trying to get an image. Say you included bundleImage.PNG in your application package .. somewhere, somehow ...
NSImage *image = [NSImage imageNamed:@"bundleImage"];
for sure .. will find him ... If he is there ... It couldn't be easier, right?
If - on time - this is a bit more complicated situation, for example, the image is in a downloadable package or structure - you can use code similar to the following (class category on NSImage), which will also return the resource.
+ (id) imageInFrameworkWithFileName:(NSString *) fileName { NSBundle *b = [NSBundle bundleForClass: [DummyClass class]]; return [self imageWithFileName: fileName inBundle: b]; }
Honestly, I really don't understand the concept or how such a "Dummy" class works, but it looks like this:
@interface DummyClass : NSObject @end @implementation DummyClass @end
source share