Skip to content

Instantly share code, notes, and snippets.

@drnic
Created December 23, 2008 00:13
Show Gist options
  • Save drnic/39199 to your computer and use it in GitHub Desktop.
Save drnic/39199 to your computer and use it in GitHub Desktop.
require 'hotcocoa'
include HotCocoa
class Application
def start
application :name => "Download And Scrape Html" do |app|
app.delegate = self
window :frame => [100, 100, 500, 500], :title => "Download And Scrape Html" do |win|
win << label(:text => "Hello from HotCocoa", :layout => {:start => false})
win << (@didReceiveResponse = label(:text => "...", :layout => {:start => false}, :frame => [0, 0, 300, 20]))
win << (@didReceiveData = label(:text => "...", :layout => {:start => false}, :frame => [0, 0, 300, 20]))
url = NSURL.URLWithString("http://github.com/drnic")
request = NSURLRequest.requestWithURL(url)
NSURLConnection.connectionWithRequest(request, delegate: self)
win.will_close { exit }
end
end
end
def connection(connection, didReceiveResponse:didReceiveResponse)
@didReceiveResponse.text = "connection_didReceiveResponse"
end
def connection(connection, didReceiveData:didReceiveData)
@didReceiveData.text = "connection_didReceiveData"
end
end
Application.new.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment