Re: [Q] Accepting URLs from other apps
Re: [Q] Accepting URLs from other apps
- Subject: Re: [Q] Accepting URLs from other apps
- From: Brian Webster <email@hidden>
- Date: Fri, 29 Mar 2002 10:46:12 -0600
On Friday, March 29, 2002, at 09:18 AM, cocoa-dev-
email@hidden wrote:
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.
The URL will be sent to your application as an Apple Event.
There are two ways that you can handle this in Cocoa:
1. Through Applescript. Using this method, you would set up a
script suite and terminology for your app and specify a command
class or method to handle the incoming event. You can look at
OmniWeb's .scriptSuite file for an example of this.
2. Register to receive the Apple event through
NSAppleEventManager. You'll want to register for event class
kInternetEventClass and event ID kAEGetURL.
If you plan on adding Applescript support to your app anyway,
then option 1 is probably best, but if you only want the basic
functionality, then option 2 is a lot simpler. In either case,
I believe that you'll also have to put some information in your
Info.plist under the CFBundleURLTypes key. Again, looking at
OmniWeb's plist will be a good example to follow.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.