?
Solved

Problem with xcode app and image files

Posted on 2004-09-29
5
Medium Priority
?
332 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
[X]
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
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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