[MacRuby-devel] Custom url scheme
Matt Aimonetti
mattaimonetti at gmail.com
Mon Jan 10 09:29:26 PST 2011
In Ruby constants start by an upper case letter, swap `kInternetEventClass'
by `KInternetEventClass' and give it a try.
For a bit more info:
http://ofps.oreilly.com/titles/9781449380373/ch01.html#_constant_names
- Matt
On Mon, Jan 10, 2011 at 9:05 AM, Martin Hawkins <martin.hawkins at gmail.com>wrote:
> I'm trying to create a custom URL scheme following the instructions
> here http://www.cocoadev.com/index.pl?HowToRegisterURLHandler and in
> the Cocoa Scripting Guide p108. I've not been getting anywhere! I've
> got at least two problems here:
> (I'm running OS X 10.6.6 with MacRuby 0.8)
>
> # Attempt #1
> # AppDelegate.rb
> # experimental
> framework 'Foundation'
> framework 'ApplicationServices'
>
> class AppDelegate
> def initialize
> registerExperimental
> end
>
> def registerExperimental
> sharedAEManager = NSAppleEventManager.sharedAppleEventManager
> sharedAEManager.setEventHandler(self, andSelector:getURL,
> forEventClass:kInternetEventClass, andEventID:kAEGetURL)
> end
>
> def getURL
> end
> end
>
> The above results produce an error -
> undefined local variable or method `kInternetEventClass'
> despite the fact that they are defined in HIServices/
> InternetConfig.h. Is this where I need to delve into the depths of
> BridgeSupport?
>
> If the above is changed to
> def getURL(event, returnEvent)
> # do something with event here to parse the url
> end
> then I get wrong number of arguments (0 for 2) (ArgumentError) which
> is what I expected, but I am confused as to how to parse the
> 'andSelector' part of the code and
> sharedAEManager.setEventHandler(self, andSelector:getURL(event,
> withReplyEvent:returnEvent), forEventClass:kInternetEventClass,
> andEventID:kAEGetURL)
> is clearly wrong.
>
> Any guidance as to how to fix these two issues will be most gratefully
> received!
> thanks
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110110/1a033121/attachment.html>
More information about the MacRuby-devel
mailing list