Solved

Problem with xcode app and image files

Posted on 2004-09-29
5
285 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now