Solved

Problem with xcode app and image files

Posted on 2004-09-29
5
312 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 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
repeateFront java challenge 31 95
Separate into files by filename 12 91
Whole sheet autoscrub still needed 19 54
maven archtype selection in eclipse 1 58
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.

726 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