• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: URL caching with XMLDoc from url
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: URL caching with XMLDoc from url
      • From: Fredrik Olsson <email@hidden>
  • Prev by Date: Re: Extract MP3 tags
  • Next by Date: Re: NSHelpManager +openHelpAnchor:inBook: Does it work?
  • Previous by thread: Re: Extract MP3 tags
  • Next by thread: Re: URL caching with XMLDoc from url
  • Index(es):
    • Date
    • Thread