kurryt
kurryt

Reputation: 210

How do I use files that I dropped into Xcode in a Mac OS X Cocoa App when running the application?

I'm creating a Cocoa Mac OS X app to install printers using a NSTask and the lpadmin command. I want to be able to use the .ppd files that are bundled with my application, e.g.

lpadmin -p name -E -v lpd://printer-location.com/public hp-laserjet-9050.ppd -L place 

How can I do this where the (.ppd) file is located in my application bundle? Should I just write the file to the current directory, install, and then delete it?

Upvotes: 0

Views: 212

Answers (1)

Anne
Anne

Reputation: 27073

Add File.ppd to the "Supporting Files" folder (Xcode 4 screenshot):

Xcode File Manager

Run lpadmin through NSTask using the following file path:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"File" ofType:@"ppd" inDirectory:nil];

Upvotes: 2

Related Questions