Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Fritz Anderson
, 2012 3:33 PM Subject: NSData DataWithContentsOfURL within a protocol handler Hello, I was callingNSData *data = [NSData DataWithContentsOfURL:url within the -startLoading of custom protocol handler, which worked fine for 10.5 through 10.7, but in 10.8, for some reason the call

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jean Suisse
Hi, Fritz Anderson is right. We can only agree. And recently, they made following Jens Alfke's advice incredibly easy. Just post a block to one of the available dispatch queues (not the one running on your main thread thought) and let it run its curse. Jean On 6 sept. 2012, at 16:36, Fritz

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Dan S
No, actually I've completely missed that it was answered. Thank you. Unfortunatelly, the requester is expecting a return data, error or a redirect. And until the api can be respeced, the sync response has to stay in. It isn't that it needs to load from network every request, but some volotile

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Dan S
if you meant using the grand central dispatch, i think that only became available in 10.6, I need to support this for 10.5 On Thu, Sep 6, 2012 at 11:25 AM, Dan S danc...@rebelbase.com wrote: No, actually I've completely missed that it was answered. Thank you. Unfortunatelly, the requester

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jens Alfke
On Sep 6, 2012, at 11:25 AM, Dan S danc...@rebelbase.com wrote: I will try to offload the server access to a different thread (though I still need to block the protocol thread because I still have to return the correct data for the current call). No — as I said before, you should _never_

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Dan S
doh! I've been treating -startLoading as a sync routine that must return a final result to the caller, and just now realized that I can return from the routine without completing the request, while the caller will be kept blocked on that request untill I respond with URLProtocolDidFinishLoading

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Dan S
hehe, yes thank you, I was definatelly treating -startLoading it as the end all call. So, following your suggestion, to avoid calling URLProtocolDidFinishLoading from the thread, what would be preferable for calling it from main thread? performSelectorOnMainthread or listening to

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jens Alfke
On Sep 6, 2012, at 1:21 PM, Dan S danc...@rebelbase.com wrote: I can return from the routine without completing the request, while the caller will be kept blocked on that request untill I respond with URLProtocolDidFinishLoading Well, the caller probably won’t be blocked, since it should be

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jean Suisse
Yes, I meant GCD. Sorry I missed the part where you told us about supporting 10.5 in your original message. On 6 sept. 2012, at 20:55, Dan S wrote: if you meant using the grand central dispatch, i think that only became available in 10.6, I need to support this for 10.5 On Thu, Sep 6,

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-05 Thread danchik
Hello, is there a recomendation of a better list for this question ? - Original Message - From: danchik danc...@rebelbase.com To: cocoa-dev-boun...@lists.apple.com Sent: Thursday, August 02, 2012 3:33 PM Subject: NSData DataWithContentsOfURL within a protocol handler Hello, I

NSData DataWithContentsOfURL within a protocol handler

2012-08-29 Thread danchik
Hello, I was callingNSData *data = [NSData DataWithContentsOfURL:url within the -startLoading of custom protocol handler, which worked fine for 10.5 through 10.7, but in 10.8, for some reason the call timesout with unknown error (256) Seems that in 10.8 any calls I make to pull the content

Re: NSData DataWithContentsOfURL within a protocol handler

2012-08-29 Thread Jens Alfke
On Aug 29, 2012, at 12:42 PM, danchik danc...@rebelbase.com wrote: Seems like it is waiting for me to return before it will process the command, is there a way I can make a syncronouse url content pull from within the -startLoading protocol handler? Don't do that. Never block the URL-loading