Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with xcode app and image files

Posted on 2004-09-29
5
309 Views
Last Modified: 2013-12-26
I have a fairly simple xcode project in c++ that opens up an image (raw file) and prints it to a window. this runs fine through xcode build and run, but the app will not execute on its own. the image is in the build folder and i draged it into the Resources group in my project. when an image is not loaded the app runs fine. any suggestions on how to solve this so the app will run using a local raw image file?
0
Comment
Question by:csugrue
  • 2
5 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12186876
How are you locating the image within the app object?

Make sure the image is part of your Xcode project under Resources->Images,
so it gets included in the app bundle.

You should be using the CFBundle APIs to locate your resources:
http://developer.apple.com/documentation/CoreFoundation/Reference/CFBundleRef

Then use the NSImage initWithContentsOfFile: or initWithContentsOfURL method
to load the image.
0
 

Author Comment

by:csugrue
ID: 12245363
hmmm. well, that sounds reasonable, but I am not sure how or where to use initWithContentsOfFile

Right now, I have a basic loadImage class that just uses fopen to load the data from local raw image file into memory. in the xcode project i have it placed in the Resources Group as mentioned. The actual file is in the build folder with the app.
0
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 125 total points
ID: 12245396
initWithContentsOfFile:  is one of the methods of the build-int NSImage class.  If you are
not using the cocoa classes (and why not?),  then use the Core Foundation CFBundle APIs
to locate your image file and use your own loadImage class to read the file as you wish.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 96
string initialization in java 11 115
haveThree challenge 22 121
canBalance challenge 34 96
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question