[英]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. 我正在创建一个Cocoa Mac OS X应用程序来使用NSTask和lpadmin命令安装打印机。 I want to be able to use the .ppd files that are bundled with my application, eg
我希望能够使用与我的应用程序捆绑在一起的.ppd文件,例如
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? 如果(.ppd)文件位于我的应用程序包中,我该怎么做? Should I just write the file to the current directory, install, and then delete it?
我应该只将文件写入当前目录,安装,然后删除它?
Add File.ppd
to the "Supporting Files" folder (Xcode 4 screenshot): 将
File.ppd
添加到“Supporting Files”文件夹(Xcode 4屏幕截图):
Run lpadmin
through NSTask
using the following file path: 使用以下文件路径通过
NSTask
运行lpadmin
:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"File" ofType:@"ppd" inDirectory:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.