Re: Obtaining an mage from a custom framework
Re: Obtaining an mage from a custom framework
- Subject: Re: Obtaining an mage from a custom framework
- From: John Hörnkvist <email@hidden>
- Date: Wed, 19 Sep 2001 15:31:05 +0200
On Wednesday, September 19, 2001, at 03:13 PM, Robert Miller wrote:
Can anyone tell me if there is a way to obtain an image via [NSImage
imageNamed] or one of the NSImage init... methods from within a
framework? I have an application that links to a custom framework I've
developed. The framework includes classes and .nib files which contain
images, etc. When I run my application I want to obtain an image that
resides in the framework I've linked to. I've tried all sorts of ways to
achieve this using file paths, etc. but no luck. Is there a way to do
this ? Am I missing something ?
Get the bundle for the framework, ask the bundle for the path to the
image file, and load it into an NSImage.
NSBundle* frameworkBundle=[NSBundle bundleForClass:[SomeClassInFramework
class]];
NSString* path=[frameworkBundle pathForResource:@"MyImage" ofType:nil];
NSImage* myImage=[[NSImage alloc] initWithContentsOfFile: path];
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com