[MacRuby-devel] Custom URL scheme (again)
Martin Hawkins
martin.hawkins at gmail.com
Tue Jan 11 08:30:01 PST 2011
I went back to this today to take it a step further and found my way
blocked - it seems to be a MacRuby thing because this is trivial to
implement in Objective-C.
This code is now:
framework 'Cocoa'
class AppDelegate
def initialize
registerExperimental
@eventDescriptor =
NSAppleEventDescriptor.descriptorWithString("this_is_a_string")
end
def registerExperimental
sharedAEManager = NSAppleEventManager.sharedAppleEventManager
sharedAEManager.setEventHandler(self,
andSelector: :"getURL:event:withReplyEvent:returnEvent",
forEventClass: KInternetEventClass, andEventID:KAEGetURL)
end
def getURL(event, withReplyEvent:returnEvent)
if event.respond_to?(:paramDescriptorForKeyword)
url = event.paramDescriptorForKeyword(keyDirectObject).to_s
end
end
def applicationShouldTerminateAfterLastWindowClosed(theApplication)
return true;
end
end
I've edited the info.plist to register 'experimental' as a custom URL
scheme and tested it by calling it in Safari.
Typing 'experimental://' in the Safari address bar produces an error:
experimental[4759]: -[AppDelegate
getURL:event:withReplyEvent:returnEvent]: unrecognised selector sent
to instance 0x200c0e240
I've tried re-writing the
'andSelector: :"getURL:event:withReplyEvent:returnEvent"' part of the
setEventHandler call every way I can think of:
andSelector:"getURL:event:withReplyEvent:returnEvent"
andSelector:"getURL:withReplyEvent"
to name but two. I'm fairly sure the whole method name has to be sent,
including the argument names, so I can't really see what is wrong. As
I say, I've constructed the Obj-C equivalent (experimental-cpp) where
typing 'experimental-cpp:///splat' produces exactly the required
response.
Any ideas anyone, please?
More information about the MacRuby-devel
mailing list