Re: howto read resources within application
Re: howto read resources within application
- Subject: Re: howto read resources within application
- From: "M. Uli Kusterer" <email@hidden>
- Date: Thu, 12 Jun 2003 12:31:01 +0200
At 18:11 Uhr +0800 12.06.2003, Bill So wrote:
1. I put a bitmap file in my project folder. Let assume the file
name be pic.png
2. I have to read pic.png within my code. And the file will also be
packaged within the application later.
Do that now. Simply drop the file into the "Resources" group in your project.
So, how do I set the path of pic.png? Is there any documentation
referring to this setting path problem?
From memory:
NSString* str = [[NSBundle mainBundle] pathForResource:"pic" withType: "png"];
printf( "%s\n", [str cString] ); // better: NSLog( "%@", str );
// pathForResource returns an auto-released string, no need to release it.
You can also use NSImage instead. It has a method (initWithName or
something like that) that simply takes the file name and it'll
automatically look up the image file in your app's Resources folder.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.