[MacRuby-devel] URI and NSURL compatibility

Mark Rada mrada at marketcircle.com
Thu Oct 7 20:11:05 PDT 2010


Hi devs,

I am trying to write a gem so that it will run on MRI and MacRuby, but still be able to take advantage of MacRuby things like Cocoa and GCD.

I was playing around with some URI related stuff and I cannot find much documentation on whether NSURL and URI objects have been bridged for MacRuby?

If they aren't bridged, I was thinking I could just hack together an empty class that just chooses if it inherits from NSURL or URI at run time.
Something like this:

	require 'uri'
	
	class HackURI 
		def initialize(uri)
			 if RUBY_ENGINE == 'macruby'
				@url = NSURL.URLWithString uri
			 else
				@url = URI.parse uri
			end
		 end
	
		def method_missing(method, *args)
			@url.send(method, *args)
		end
	end 

--
Mark Rada



More information about the MacRuby-devel mailing list