From: Steve C. <sco...@gm...> - 2009-02-14 19:35:49
|
Exactly On 2/14/09, Allison Newman <dem...@ma...> wrote: > Steve, > > Just to clarify, you're trying to subclass NSURLProtocol, and you want > to override/create functions that are to be called from Objective C, > Is that right? > > Alli > > Le 14 févr. 09 à 18:02, Steve Conover a écrit : > >> Hi everyone. >> >> I'm trying to make my own URL Protocol. I've been marching along >> pretty well but have hit a hang problem - if you can spot the problem >> I'd appreciate help, but I might be even more interested in what you'd >> do to debug the problem - I don't even know what to try next. >> >> It seems that I've defined startLoading properly - the framework >> complains if it's not there, or the method signature is incorrect. >> canonicalRequestForRequest gets called and then the whole operation >> hangs - startLoading never gets invoked. >> >> >> My class: >> >> require 'osx/cocoa' >> >> OSX.require_framework 'WebKit' >> >> class LocalProtocol < OSX::NSURLProtocol >> >> objc_class_method(:canInitWithRequest_, '@:@@') >> def self.canInitWithRequest(ns_url_request) >> p" canInitWithRequest" >> 0 >> end >> >> objc_class_method(:canonicalRequestForRequest_, '@:@@') >> def self.canonicalRequestForRequest(ns_url_request) >> p"canonicalRequestForRequest #{ns_url_request.inspect}" >> ns_url_request >> end >> >> def startLoading >> p "startLoading" >> end >> >> def stopLoading >> p "stopLoading" >> end >> >> end >> >> >> >> Calling code: >> >> protocol = LocalProtocol.alloc >> >> OSX::NSURLProtocol.registerClass(LocalProtocol) >> >> url = OSX::NSURL.alloc.initWithString("local://foo") >> url_request = OSX::NSURLRequest.requestWithURL(url) >> url_response = OSX::NSURLResponse.alloc >> response = >> OSX >> ::NSURLConnection >> .sendSynchronousRequest_returningResponse_error(url_request, >> url_response, nil) >> str = "." * response.length >> response.getBytes_length(str) >> >> >> Console result: >> >> " canInitWithRequest" >> " canInitWithRequest" >> " canInitWithRequest" >> "canonicalRequestForRequest #<OSX::NSURLRequest:0x8beeee >> class='NSURLRequest' id=0x2003e50>" >> <HANGS HERE FOREVER> >> >> >> Regards, >> Steve >> >> ------------------------------------------------------------------------------ >> Open Source Business Conference (OSBC), March 24-25, 2009, San >> Francisco, CA >> -OSBC tackles the biggest issue in open source: Open Sourcing the >> Enterprise >> -Strategies to boost innovation and cut costs with open source >> participation >> -Receive a $600 discount off the registration fee with the source >> code: SFAD >> http://p.sf.net/sfu/XcvMzF8H >> _______________________________________________ >> Rubycocoa-talk mailing list >> Rub...@li... >> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > -- Sent from my mobile device |