Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rate Thread Display Modes
Old 09-07-2011, 08:38 PM   #1
snackers
Prospect
 
Join Date: Sep 2011
Posts: 1
how to add image resources in XCODE?

Hello, I want to add an image resource (like bmp) into xcode and read its contents. I already tried putting the image file directly to the project folder, but I still get the 'file not found' error. How do I do this in xcode?
snackers is offline   Reply With Quote
Old 09-08-2011, 02:10 PM   #2
szymczyk
Prospect
 
Join Date: Aug 2005
Posts: 45
Start by adding the image file to the project. If you're using Xcode 3, the easiest thing to do is select the project's Resources folder in the Groups and Files list, right-click and choose Add > Existing Files.

After adding the image file to the project, you must make sure the file is in the target's Copy Bundle Resources build phase. The image file must be in the Copy Bundle Resources build phase for Xcode to add the image file to your application bundle when you build the project. In Xcode 4, select the project file from the project navigator to open the project editor. Select the target from the project editor and click the Build Phases button at the top of the project editor. If you're using Xcode 3, the image file should be in the Copy Bundle Resources build phase if you followed my instructions in the first paragraph.

In your code use either Cocoa's NSBundle class or Core Foundation's CFBundle functions to locate the image file. After locating the image file, open the file and read its contents. Apple has several options for opening and reading files.
__________________
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
szymczyk is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.