Re: URL caching with XMLDoc from url
Re: URL caching with XMLDoc from url
- Subject: Re: URL caching with XMLDoc from url
- From: Eric Blanpied <email@hidden>
- Date: Tue, 1 Aug 2006 01:20:41 -0700
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden