简体   繁体   English

在运行应用程序时,如何使用我在Mac OS X Cocoa App中放入Xcode的文件?

[英]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屏幕截图):

Xcode文件管理器

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.

相关问题 当文件,图片等放在其停靠栏图标上时,如何让OS X应用程序做出反应? - How do I make an OS X application react when a file, picture, etc is dropped on its dock icon? 在哪里可以下载 OS X 10.10 SDK 以在 Xcode 6.3 中运行 Mac 应用程序? - Where I can download for OS X 10.10 SDK for running a Mac Application in Xcode 6.3? 在Mac OS X App Cocoa中生成图像文件的问题 - issue in generating image files in mac os x app cocoa 如何在Mac(可可)应用程序中实现夜间模式? - How do I implement night mode in Mac (Cocoa) application? 如何在系统启动时启动应用程序? (Mac OSX,Cocoa) - How do I launch an application on system startup? (Mac OSX, Cocoa) 在Xcode中,如何链接动态库(libcurl)以便该应用程序也适用于旧版本的Mac OS? - In Xcode, how do I link a dynamic library (libcurl) so that the app also works on older versions of the Mac OS? 如何在Mac App Store上的os x应用程序中捆绑命令行实用程序(使用沙箱权利) - How can I bundle a command line utility in os x application on Mac App Store (using sandbox entitlement) 如何在 Mac OS X 10.15.2 (Catalina) 上使用 Obj-C、Xcode 11.3.1 在代码中重新定义应用程序窗口的大小/来源,覆盖 nib/xib 文件参数? - How do I re-define size/origin of app window in code, overriding nib/xib file parameters, with Obj-C, Xcode 11.3.1 on Mac OS X 10.15.2 (Catalina)? 如何表示用户通过电子邮件发送给我的Mac OS X应用程序的崩溃报告? - How do I symbolicate a crash report of a Mac OS X app that a user emailed to me? 如何在Mac OS X上获取默认临时目录? - How do I get the default temporary directory on Mac OS X?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM