[Q] Accepting URLs from other apps
[Q] Accepting URLs from other apps
- Subject: [Q] Accepting URLs from other apps
- From: Kyle Hammond <email@hidden>
- Date: Fri, 29 Mar 2002 01:30:19 -0600
Hi all,
I'm trying to make an app that can accept a URL from any other app.
I've found lots of messages in the archives pertaining to using
NSWorkspace's -openURL: method to SEND a NSURL to the default app, and
lots of messages about downloading a NSURL you already have, but how do
I ACCEPT such a NSURL from NSWorkspace (meaning some other app called
-openURL:)? For example, if the user encounters a news or nntp link on
a web page and clicks it, I want my app to open that news link.
First, assume the user has used the Network System Preferences pane to
set this app as the default app for the "News" format. I'm assuming
that will handle both "news" and "nntp" URLs. Maybe a bad assumption,
so tell me if it is and what I'd need to do to register for both. Maybe
it's time to get down and dirty with Internet Config via Carbon.
Do I need to add any keys to my apps Info.plist file? I was be able to
select any old application using the System Preferences, so I'm guessing
that Apple doesn't check for any specific keys before sending the URL.
My application is currently not document-based, but I had thought that I
would need to make a subclass of NSDocument to handle incoming URLs.
Then it would be a simple matter of overriding -readFromURL:ofType: and
doing what I wanted with the incoming URL.
However, I don't know how to set up the mapping between the URL type and
the document class. The standard document type keys didn't seem to work
when I put in things like "news" or "nntp" for the file extension or OS
types. The URL Types interface is operational in PB, but the only
documentation I found on it says that it's use is "under discussion"
within Apple.
Is there any way for the application delegate or a subclass of
NSDocumentController to accept the incoming URL or do I have to go with
a NSDocument subclass? If NSDocument subclass, how do I set up the
Info.plist keys?
Thanks for any help,
Kyle
P.S. I've just spent the better part of four hours poring over the
archives here and on the Omni site as well as reading every scrap of
Apple docs that may pertain to my question. I looked through the
AppleScript documentation, thinking that in Carbon, the URL would come
in through an AppleEvent, but I'd really like to stick to Cocoa if
possible. I even went so far as to subclass NSApplication and log
everything going through the
-nextEventMatchingMask:untilDate:inMode:dequeue: method which turned out
to not even see the incoming URL at all as far as I could tell. I'm
finally willing to ask for help.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.