Does -dataWithContentsOfURL: of NSData work in a background thread?
+1
A:
No, it blocks the current thread.
You need to use NSURLConnection in order to have asynchronous requests.
Jacob Relkin
2010-06-20 09:36:53
+2
A:
No, it doesn't.
In order to get data from URL asynchronously you should use the NSURLRequest and NSURLConnection approach.
You will have to implement the NSURLConnectionDelegate methods:
- -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
- -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- -(void)connectionDidFinishLoading:(NSURLConnection *)connection;
- -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
Michael Kessler
2010-06-20 09:38:20