Re: How to find the file (url) that was double-clicked to open my Cocoa Application?
Re: How to find the file (url) that was double-clicked to open my Cocoa Application?
- Subject: Re: How to find the file (url) that was double-clicked to open my Cocoa Application?
- From: Motti Shneor <email@hidden>
- Date: Mon, 04 Apr 2016 14:55:06 +0300
OK. I’ll have to answer my own question. Please forgive me answer is neither definitive nor complete, and is ugly - but it works.
Generally:
1. In a Document based application - the [[[NSDocumentController sharedController] documents] firstObject] will give you also access to the file.
2. In a non-document based application - If you have the NSWindow of the open document, you can use [NSWindow representedURL] to get to the file.
However:
3. Alas - my Installer plugin bundle,throughout its lifecycle, has all its NSView’s window property set to nil. Also, within the Installer App, [NSDocumentController sharedController] documents] is always empty too.
My final workaround was to use [[NSApp mainWindow] representedURL] when my installer plugin was called with- (void)willEnterPane:(InstallerSectionDirection)dir which is called from the main-window as the user clicks a “next” button on the installer previous stages. It works - although very ugly hack.
Hope it will help someone out...
> On 30 Mar 2016, at 20:11, Jens Alfke <email@hidden> wrote:
>
>
>> On Mar 30, 2016, at 1:47 AM, Motti Shneor <email@hidden <mailto:email@hidden>> wrote:
>>
>> But still, If a package file was double-clicked to launch the Installer App, and it received an “Open File” event, is there a way to get to the file later on, without actually catching this event?
>
> No, not as far as I know. It’s an ‘odoc’ AppleEvent sent to the app at launch time, and handled by NSApplication, and that info isn’t kept around for later because there isn’t generally any need for it.
>
> I think you’ve got an Installer-specific issue after all.
>
> —Jens
Motti Shneor
e-mail: email@hidden
phone: +972-8-9267730
mobile: +972-54-3136621
---
Ceterum censeo Microsoftinem delendam esse
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden