Prashant Cholachagudda
Prashant Cholachagudda

Reputation: 13092

How to get content from URL asynchronously?

I'm trying here to create NSXMLParser from content of URL, it work perfectly well but is there way I can make URL content to be received asynchronously and later create NSXMLParser?

NSURL *url = [[NSURL alloc] initWithString: @"http://www.Xmlfile.com"];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[url release];

Upvotes: 0

Views: 1841

Answers (1)

Daniel Dickison
Daniel Dickison

Reputation: 21882

Use NSURLConnection to fetch the data asynchronously into an NSData, then use initWithData instead of initWithContentsOfURL.

Upvotes: 2

Related Questions