Hi Chris, On Oct 1, 2008, at 11:17 AM, Chris Williams wrote:
I am trying to port StarJour ( http://github.com/lachie/starjour/tree/master ) over to MacRuby and need some assistance with how to override delegate functions for the NSNetServiceBrowser Is there somewhere (tutorial RFTM?) I can use to find this?
Implementing delegate methods is done the same way you would do it in Objective-C. Example: browser = NSNetServiceBrowser.new delegate = Object.new def delegate.netServiceBrowserWillSearch(browser) puts "search commencing!" end def delegate.netServiceBrowser(browser, didNotSearch:errorInfo) puts "search not successful: #{errorInfo}" end browser.delegate = delegate browser.searchForBrowsableDomain, You could also implement the delegate methods in a separate class and pass a new instance of that class to the setDelegate: method (available as #delegate= too) of the net service browser object. Creating Objective-C selectors from MacRuby is discussed in the "Defining Methods" section of the tutorial: http://www.macruby.org/trac/wiki/MacRubyTutorial HTH, Laurent