purpose of using NSURLConnection while calling xml web-service ..?
<p>why we are using NSURLConnection object in xml parsing ie.</p>

<p>for eg:</p>

<pre><code>NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

and then NSURLConnection delegate methods invoked
like:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
    [connection release];
    [receivedData release];

}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{  
    [receivedData setLength:0];

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 
    [receivedData appendData:data];

}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

    if(ObjNSXMLParser!=nil &amp;&amp; [ObjNSXMLParser retainCount]&gt;0){
        [ObjNSXMLParser release];
        ObjNSXMLParser = nil;
    }

    ObjNSXMLParser = [[NSXMLParser alloc]initWithData:receivedData];
    ObjNSXMLParser.delegate=self;
    [ObjNSXMLParser parse];

}
</code></pre>

<p>===============================
But we also get data directly by using: no need to initialize NSURLConnection object:</p>

<pre><code>NSData *dt = [NSData DatawithcontentsofURL:urlname];
</code></pre>

<p>which approach is best ?and why ?</p>
