views:

60

answers:

1

Hey.

I am currently using [NSString stringWithContentsOfURL:url] to download the contents of an external webpage to my app.

Is there any other way that might be faster or better/safer?

+2  A: 

look up NSURLConnection. It runs asynchronously and therefore won't slow down or temporarily crash your application.

Thomas Clayson
I am running this in the background already, so no need for more asyncness :)
Emil
But I will try out NSURLConnection.
Emil
well it might be ok anyway, what it does is it gets the remote file in strings of data. :) so you just string all the data together into an NSString. :)
Thomas Clayson
With NSURLConnection, you can distinguish whether the URL points to an empty file, or the network connection somehow failed and returned something empty. That's sometimes quite important.
Yuji
And NSURLConnection proved to be 3,5 seconds faster! Thanks :) @Yuji Yep, that's great for me.
Emil