• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Easy question about URLs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy question about URLs


  • Subject: Re: Easy question about URLs
  • From: James Bucanek <email@hidden>
  • Date: Thu, 22 Mar 2007 13:38:14 -0700

James Bucanek wrote on Friday, March 9, 2007:
>What I'd like to do is have my application open a document at a particular location. I'd like to do
>this by pasing the application an url to open in the form
>'file:///path/to/document.doc?at=location/in/document'.
>
>Will the parameter portion of the URL survive the trip through [NSWorkspace openURL:...] through
>[NSDocumentController documentForURL:]? What's the best way to encode, add, and ultimately decode the
>parameter portion of the URL. I don't see any tools in NSURL for manipulating the parameter portion
>of an URL.

To answer my own question, it appears that this won't work. From what I can gather, the OS handles open requests with a file:// URLs by first converting it into a standard open AppleEvent, which gets turned back into an URL by the Cocoa framework. In translating from file URL to alias and back to URL again, all of the URL parameters are lost.

So is there any reasonably quick techniques for implementing something like this? I'd really like to get this working quickly (like, within a day).

One obvious solution is to make my application fully AppleScriptable. While that's a long-term goal, it's not going to happen in the short term.

It is possible to create an open AppleEvent with an additional parameter that could be extracted during the open document message? Does anyone have code showing how this might happen. I'm not excited about this because the last time I implemented AppleEvents in an application I became suicidal. :(

I also considered adding a protocol so my app would received URLs like 'mybad:///document#location', but that's ugly for several reasons. And I'm still not entirely sure how my application would get the URL -- the ADC Reference Library seems to have very little to say on how URLs get past to Cocoa applications.

My fall back plan is to create a "bookmark" document type. The open at location request would write the location information to a temporary "bookmark" file, then tell my application to open the temporary file.

--
James Bucanek
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

  • Follow-Ups:
    • Re: Easy question about URLs
      • From: Nir Soffer <email@hidden>
References: 
 >Easy question about URLs (From: James Bucanek <email@hidden>)

  • Prev by Date: Dragging files to ImageApp
  • Next by Date: Re: Dragging files to ImageApp
  • Previous by thread: Re: Easy question about URLs
  • Next by thread: Re: Easy question about URLs
  • Index(es):
    • Date
    • Thread