开发者

How to access dropped files in a droplet style cocoa application

开发者 https://www.devze.com 2023-01-13 22:06 出处:网络
Pretty much all the apps I use on a regular basis implement this \'seemly simple\' scenario, yet I can\'t replicate this 开发者_开发问答in my own Cocoa application. Please consider these steps:

Pretty much all the apps I use on a regular basis implement this 'seemly simple' scenario, yet I can't replicate this 开发者_开发问答in my own Cocoa application. Please consider these steps:

  1. The application is not running
  2. You drop a file, or a selection of files onto the app's icon.
  3. The app runs and performs some actions on the dropped files.
  4. Maybe it opens them, maybe not, but stuff happens.

When I try googling the answer, some of them even here on stackoverflow point me towards the NSApplicationDelegate's application:openFiles: method. The explanation on how to get from Apple events to the delegate is here.

With the proper UTIs in place (****), this works like a charm when the application is already running. However, since I'm trying to make a 'droplet' style application, I want it to also work when the app is not yet running.

And in this last scenario, the application:openFiles: method is not called. Right now I have only a simple NSLog() call in there, and it doesn't show (I'm looking at the Console.app, since it's kinda hard simulating a dropped file on build in XCode).

Can someone tell me where to look, what to do, what to change?

Cheers, Eric-Paul.


This is actually really rather simple: The application is likely not registered with launch services. Try installing it in your Applications folder, and see if that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消