Link to home
Start Free TrialLog in
Avatar of csugrue
csugrue

asked on

Problem with xcode app and image files

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?
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

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.
Avatar of csugrue
csugrue

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial