Skip navigation.
 
mlRe: URL caching with XMLDoc from url
FROM : Eric Blanpied
DATE : Tue Aug 01 10:20:41 2006

On Jul 31, 2006, at 11:47 pm, Fredrik Olsson wrote:

> Eric Blanpied skrev:

>> I'm using NSXMLDocument's initWithContentsOfURL: method, and I 
>> think I'm running into some issues with NSURL caching the data at 
>> times. I see that there are lots of options with NSURLRequest and 
>> it's brethren, but it's not clear to me how to merge this with the 
>> NSURL required by NSXMLDocument's initWithContentsOfURL:
>>
>> Any pointers on this would  be great.
>>

> The NSURL instance that NSXMLDocument's 
> initWithContentsOfURL:options:error: wants is simply just an URL, 
> like http://foo.com/xml.php or file://Users/peylow/test.xml.
>
> The NSURLRequest is a bit more complex, it can also post form data 
> and such. I can not see any way to swap the two unless you also use 
> the NSURLRequest object with a NSURLConnection's 
> sendSynchronousRequest:returningResponse:error: method to get a 
> NSData object. And then use that to init the NSXMLDocument using 
> the initWithData:options:error: method instead.
>
> Something like:
> NSURL *url = [NSURL URLWithString:someURLString];
> NSURLRequest *request = [NSURLRequest requestWithURL:url];
> NSURLResponse *response;
> NSData *data = [NSURLConnection sendSynchronousRequest:request 
> returningResponse:&response error:nil];
> NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data 
> options:NSXMLNodeOptionsNone error:nil];
>
> But my guess is that this is pretty much what 
> initWithContentsOfURL:options:error: does internally anyway.
>
>
> // Fredrik Olsson


Would that allow me to control the caching better?

-e

Related mailsAuthorDate
mlURL caching with XMLDoc from url Eric Blanpied Jul 31, 20:00
mlRe: URL caching with XMLDoc from url Fredrik Olsson Aug 1, 08:47
mlRe: URL caching with XMLDoc from url Eric Blanpied Aug 1, 10:20
mlRe: URL caching with XMLDoc from url Fredrik Olsson Aug 1, 11:18