From: s.ross <cw...@gm...> - 2009-09-18 17:25:11
|
I've been mostly successful translating pertinent Apple Obj-C signatures into Ruby, but the ones here: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html in listing 1, are baffling me. I'm just not sure what I'm supposed to be delegating to, so I get Objective-C method signature for selector 'delegate:method:' of receiver #<here's what I don't know>. I've seen some examples of synchronous HTTP requests, but this seems more the way Apple advocates. Here's my code (not working) for reference: class Controller < NSObject include OSX def sendRPCTest # Code modeled after: http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836 theRequest = NSURLRequest::requestWithURL_cachePolicy_timeoutInterval( NSURL::URLWithString("http://www.apple.com/"), 0, 60.0) # Ok, here's the sticky part. I can't figure out how to get the connection, given the request delegate_method ???what??? do theConnection = NSURLConnection::initWithRequest(self) end if theConnection @receivedData = nil else NSLog("no data to download") end end end Thanks in advance, Steve |