Permalink
Browse files

indentation and comment fix

Signed-off-by: Dr Nic Williams <drnicwilliams@gmail.com>
  • Loading branch information...
1 parent ef6b2ec commit 5bbe973c5f23431f55ec72ad5a79830794d59294 @mattetti mattetti committed with Dec 30, 2008
Showing with 13 additions and 11 deletions.
  1. +13 −11 download/lib/application.rb
@@ -4,10 +4,10 @@
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})
+ 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 << (@status = label(:text => "...", :layout => {:start => false}, :frame => [0, 0, 300, 20]))
win << (@data = text_field(:text => "...", :layout => {:start => false}, :frame => [0, 0, 480, 400]))
@@ -18,24 +18,26 @@ def start
end
def initiate_request(url_string, delegator)
- url = NSURL.URLWithString(url_string)
- request = NSURLRequest.requestWithURL(url)
+ url = NSURL.URLWithString(url_string)
+ request = NSURLRequest.requestWithURL(url)
@connection = NSURLConnection.connectionWithRequest(request, delegate: delegator)
end
# Deal with the data response
#
- # Note: in MacRuby, the method signature makes a method unique
- # two methods can have the same name but different signatures
+ # Note: in Ruby, the method name is the method signature
+ # Objective C uses what's called a selector
+ # The objc selector for the method below would be:
+ # `connection:didReceiveResponse:`
def connection(connection, didReceiveResponse:response)
@status.text = (response.statusCode == 200) ? "Retrieving latest videos" : "There was an issue while trying to access the latest videos"
end
def connection(connection, didReceiveData:receivedData)
- @status.text = "Data retrieved"
- page = NSString.alloc.initWithData(receivedData, encoding:NSUTF8StringEncoding)
+ @status.text = "Data retrieved"
+ page = NSString.alloc.initWithData(receivedData, encoding:NSUTF8StringEncoding)
NSLog(page)
- @data.text = page
+ @data.text = page
end
end

0 comments on commit 5bbe973

Please sign in to comment.